Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
How do I make OS X set the terminal title back to the original title when coming back from ssh?

Every time you logout from a SSH connection in Mac OS X terminal you end up with the past login information in the window title.

Most solutions I have found searching on the web involves playing around con escape sequences, like this question or this related blog post.

It seems to be a SSH issue, not a Terminal thing, so I was wondering if there is an easier way of doing this (maybe editing SSH client configuration?).

share|improve this question

marked as duplicate by Daniel Beck Sep 1 '12 at 22:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

1 Answer

up vote 10 down vote accepted

It's not an SSH issue. The issue is that the shell on the remote host is configured to send an escape sequence to set the terminal window title. This is a fairly common setup. The solutions mentioned in the blog post you linked to are correct.

The simplest and most direct solution is to configure that same remote shell to reset the window title when it logs out. e.g., if the remote shell is bash, put this in ~/.bash_logout:

printf '\e]0;\a'

Alternatively, if you'd like to have your local shell update the window title with something useful, anyway, then do that. When the ssh connection ends, the local shell will set the window title to something else instead of leaving the stale value. e.g. put this in ~/.bashrc:

PS1='\[\e]1;\s\$ \W\a\e]2;\u@\h\a\]'"$PS1"

This puts the user and host name in the window title (which is typically what remote shells are configured to do), and also sets the tab title to show the shell name and type (normal user or root) and current working directory.

Note that if you don't already have a ~/.bash_profile (or ~/.profile), create one and have it run ~/.bashrc so that ~/.bashrc applies to login and non-login shells:

if [ -f $HOME/.bashrc ]; then
    . $HOME/.bashrc
fi
share|improve this answer
    
Thanks! It helped a lot. –  m_gol Oct 18 '12 at 15:14
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.