my Macbook air is called Johannes-Air. But when I open the terminal sometimes it says Johannes-Air and sometimes johannes-air. Does anyone know why this happens and how to stop it?
2 Answers
The local hostname (is set in the Sharing pane of System Preferences) check it at first.
Then if you go to the below path, you might find traces of both upper & lower case hostname remove one of them and reboot your system.
/Library/Preferences/SystemConfiguration/preferences.plist.
I've been dealing with this for a few weeks and just discovered that it seems to be related to my local DHCP / DNS server (pfsense + unbound in my case).
baseline (WiFi on, connected to my home network):
$ hostname -s
myhostname
WiFi off:
$ hostname -s
MyHostName
WiFi back on again:
$ hostname -s
myhostname
WiFi on + VPN connected (with DNS leak protection):
$ hostname -s
MyHostName
So in my case, it looks like pfsense may be normalizing the hostname that it returns when I'm connected to my local network. This is causing some issues with my flake-based nix-darwin setup, so I think I'll configure my hostname to be lowercase to match: sudo scutil --set HostName myhostname
.
There is also some helpful information including commands to manipulate your hostname at this related question.