For a last few days my Macbook “assumed” a weird hostname: kousik-mac(2) — I don’t know what I did that caused it. Here are three ways to change it (I don’t know if these qualify to be “NIX tricks” :D):
1. Click at the Sharing option in System Preferences and then click at Edit. You may change the computer name as well.
2. Use the following commandline-fu:
$ sudo scutil --set HostName your-preferred-hostname
3. Edit the preference file
$ sudo vi /Library/Preferences/SystemConfiguration/preferences.plist
Search for LocalHostname and change the text within theĀ <string>...</string> just under it. While you’re at it, you may want to change the string under ComputerName (need I say what it does?), as well — this key comes just after the previous one (HostName).