Unexpected changes to command line
This is a bug in the implementation of iOS/OS X in my eyes. What used to be a good thing is now a pain in the behind.


Computer name keeps changing OSX 10.10 (14A389)
Why does an iPhone rename itself with (2)
My Mac mini&#39;s computer name keeps changing when it resumes from sleep


This has been something that people of Apple products have been dealing with since 2012 on a widespread basis. It's easier to fix on OS X where you can call the scutil command:

scutil --get ComputerName
scutil --set ComputerName "Whatever You Wish"


The only positive thing is that in some cases, people depend on host names so making the change visible in the terminal has some benefit for them, but it sure causes a lot of worry and concern when people see names they have chosen being ignored and reassigned/modified without any reasonable explanation as to why being presented to the user. On the practical end, there is absolutely no good way to prevent this renaming - either setting things up on the network router side or on OS X side given that the OS manage IPv4 and IPv6 and AirDrop and bluetooth networks and shuffle the network settings to accommodate many clients.