A tip for those who are running Tiger and want to change the hostname that shows up in their terminal prompt.

In the past, on pre-Tiger systems, folks were told to edit their /etc/hostconfig file and change the hostname variable from AUTOMATIC to yourhostnamehere. This was to forestall the ever-changing prompt problem, which annoys laptop users who move from network to network and could find themselves ‘jsmith@dhcp-123.45.6.7′ or ‘jsmith@nameofbox’ or any number of things, depending on where they were.

That HOSTNAME=-AUTOMATIC- variable is missing from a fresh install of Tiger, however, and from what I’ve been able to research, Tiger no longer uses it anyway. :) But rather than bothering with that, you can just edit the way your prompt looks using your .bash_profile file.

Bash is the Bourne Again Shell, the usual default CLI shell on Linux and (nowadays) Mac. Which is handy if you flit between the OSs. You can control various options for your Terminal experience inside an invisible file named ‘.bash_profile’ in your home directory. Invisible to the Finder, at least, but editable from within the Terminal. So if it doesn’t exist, you can create it using vim or nano or emacs or whatever your favorite CLI text editor is.

Add these lines to .bash_profile to get the unchanging hostname and a little bit of enhancement from the default prompt, assuming you wanted the hostname to be ‘mithrandir’:

PS1="[u@mithrandir:w] "case `id -u` in     0) PS1="${PS1}# ";;     *) PS1="${PS1}$ ";;esac

Prompt-futzing is a dear old tradition in geek circles and a good example of the true necessity of spending a few hours hacking in order to save less than a minute every day. :)

Got any favorite CLI prompt futzes?