How do I stop automatic changing of iterm tab titles?

Go to Iterm's Preferences > Profiles > Terminal

Uncheck "Terminal may set tab/window title"

Now you can name your tab, ssh into a server, exit and still keep the original tab name.

Credit to: https://groups.google.com/forum/#!topic/iterm2-discuss/czV-sv4ykzI

Cheers, Alan


Make sure $PROMPT_COMMAND is not set by running

echo $PROMPT_COMMAND

If the output is non-empty, that script is executed just before a prompt is displayed by the shell.


On OS X Lion, the default value is update_terminal_cwd, and it looks like this:

$ type update_terminal_cwd
update_terminal_cwd is a function
update_terminal_cwd () 
{ 
    local SEARCH=' ';
    local REPLACE='%20';
    local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}";
    printf '\e]7;%s\a' "$PWD_URL"
}

It is used to add the current working directory to Terminal's title bar.


To prevent hosts you ssh into from changing the title, usually doing

export TERM=vt100

before you ssh does the trick, because the default initialization files (bashrc etc) look at the terminal variable and only change the title if the terminal is xterm (which nowadays is the de facto standard).

Note: with this trick you lose at least "alternate screen", colors and maybe other kinds of fancy terminal features you may or may not appreciate.