Friday, June 20, 2008

Dynamic terminal titles

I generally have multiple terminal windows open when working on linux and often it gets confusing figuring out which host/directory each terminal is in. The following lines in my .bashrc file get me dynamic titles for my xterm or gnome-terminal windows in linux or putty. Titles change every time I change directories, with my home directory (for ex. /home/atul) replaced with a '~'.

export SHORT_HOSTNAME=`hostname -s`
PROMPT_COMMAND='echo -ne "\033]0;$SHORT_HOSTNAME: ${PWD/$HOME/~}\007"'