I've been using Linux for almost 10 years now, so I'm used to the command line. Most of the windows in my GNOME desktop are GNOME Terminals. And when you have many of them, you'd like to distinguish them somehow in the window list or window selector applets.

My .bashrc specifies a $PROMPT_COMMAND that sets the username, hostname and the current working directory in the title bar. I can therefore distinguish root terminals and remote terminals (ssh rules), and terminals where I work on different projects in different directories. Until recently I couldn't, however, distinguish the terminal which was running Zope 3 from a terminal which was running functional tests from a terminal which was running an svn update.

For a long time I wanted to see the currently executing command in a terminal title. I always thought this was impossible with bash. David Pashley proved me wrong. I had to change his recipe a little bit, because it interferes with $PROMPT_COMMAND in a nasty way. Here's my .bashrc now:

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'

    # Show the currently running command in the terminal title:
    # http://www.davidpashley.com/articles/xterm-titles-with-bash.html
    show_command_in_title_bar()
    {
        case "$BASH_COMMAND" in
            *\033]0*)
                # The command is trying to set the title bar as well;
                # this is most likely the execution of $PROMPT_COMMAND.
                # In any case nested escapes confuse the terminal, so don't
                # output them.
                ;;
            *)
                echo -ne "\033]0;${USER}@${HOSTNAME}: ${BASH_COMMAND}\007"
                ;;
        esac
    }
    trap show_command_in_title_bar DEBUG
    ;;
*)
    ;;
esac