MacOS Terminal – Why is Hostname Set to a Random Number in Bash Prompt?

bashmacosterminal

Today I saw that when I open a terminal, the bash prompt displays username@228~:. When I type in pwd I get /Users/username so I was wondering where does this 228 come from? It wasn't like that couple of days ago and I am not sure what introduced this change.

My OS is OS X Yosemite 10.10.5.

In .bash_profile I have export PS1="\u@\h\w: ".

Best Answer

From the list of prompt strings (see PROMPTING in man bash):

\h     the hostname up to the first `.'

Usually, this gives a nice short hostname but in your case leads to the slightly confusing 228.