Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm running gnome-terminal set to update its title according to terminal commands updating their own titles (default on Fedora 13). When I SSH to somewhere else the title is updated correctly, but then SSH exits and gnome-terminal is indicating that I'm still logged in remotely. This is confusing when trying to navigate around. How do I maintain the behaviour when logging in, and restore the old title when logging out (by default just "Terminal", but better yet display current location)?

share|improve this question
Which shell are you using on the local side? – Ignacio Vazquez-Abrams Oct 15 '10 at 9:54
Don't have access right now, pretty sure it's bash though - whatever is default for gnome-terminal on Fedora 13. – Sam Brightman Oct 16 '10 at 6:01

1 Answer 1

up vote 6 down vote accepted

Add the set-title escape sequences to your shell's rc file. For bash v4, this would be:

if [[ $TERM == xterm* ]]; then
    # This puts "user@host workdir" into the titlebar.
    # (look for section "PROMPTING" in bash's manual)
    title='\u@\h \w'


in your ~/.bashrc.

Stop reading here unless you like messing with bash scripts.

The code above is actually a greatly simplified version of my ~/.bashrc snippet:

case $TERM in
    # only set the "screen"window title

# Very useful for: title syslog && tailf /var/log/syslog
title() { [ "$title_seq" ] && printf "$title_seq" "$*"; }

# Modify the prompt string.
if [ "$title_seq" ]; then
    title='\u@\h \w'
    PS1+="\[$(printf "${title_seq//\\/\\\\}" "$title")\]"

Actually, that was my old ~/.bashrc snippet. Upon discovering PROMPT_DIRTRIM=1 I had to replace the $PS1 modification (the last if statement) with:

update_title() {
    title "$USER@$HOSTNAME ${PWD/#$HOME/~}"
share|improve this answer
Thanks, love it. @Sam-Brightman : Please accept this answer. – vasquez Nov 18 '11 at 11:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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