I have my bash_profile
on my Mac and the remote computers I connect to setup to automatically put the hostname in the window's (or tab's) title area.
A bash shell on my local machine
A remote host name "Socrates"; also a bash shell.
The problem is, when I exit (and disconnect) from the remote host, the window title stays with the host name of the remote. So, in effect, I'm on the local Apple bash shell with the remote name. To fix it, I do one of the following:
- close the window and open a new one
- re-source the
.bash_profile
(. ~/.bash_profile
) - create a new sub shell by issuing the command
bash
(not desirable at all)
How can I have this done automatically so that when I exit a remote shell, the title goes back to the original host name so I know what host I'm actually connected to?
Note, the previously asked question, Terminal displays directory of previous SSH location even when not running SSH didn't adequately address the issue because the solution was to modify .bash_logoff
which only worked for login shells.
.bash_logout
. And the answer you've posted below would be equally valid for the other question as well.