Starting on OS X, I ssh into foo (a Linux box). My terminal title changes to foo. I then ssh into bar (another Linux box). My terminal title changes to bar. I log out of bar. My terminal title changes to foo. I log out of foo. My terminal title stays foo (rather than changing back to the original title). The problem is obviously not with the terminal, since it works correctly when logging out of a Linux box back to a Linux box. It probably isn't ssh as I have the same problem with vim. In my mind that leaves the shell. I am using BASH. Looking through the environment I don't see a lot of difference between the Linux box and my OS X box. Both are using a TERM of xterm.
MacOS – How to make OS X set the terminal title back to the original title when coming back from ssh
bashmacosshellsshterminal.app
Best Answer
Adding
to my
.bash_profile
fixed the problem.It appears as if the string in
PROMPT_COMMAND
gets executed every time the prompt is displayed. From the man page: