OS X Update Terminal Tab Text with PROMPT_COMMAND

• Updated May 31, 2014

From Mac OS X 10.3 to OS X 10.8, the Terminal application has always had a problem updating its tab text when disconnecting from an SSH server.

The tab text will update properly when connecting to an SSH server, but upon disconnecting, it will still show the FQDN of the server you were connected to.

Place the following in ~/.bash_profile to fix this:

export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}"; echo -ne "\007"'

Now, re-source your .bash_profile, source ~/.bash_profile, or log out and log back into your shell for the changes to take effect.

If you found this post useful and would like to help support this site - and get something for yourself - sign up for any of the services listed below through the provided affiliate links. I will receive a referral payment from any of the services you sign-up for.

Get faster shipping and more with Amazon Prime: About to order something from Amazon but want to get more value out of the money you would normally pay for shipping? Sign-up for a free 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.

Thanks for reading and take care.