User Tools

Site Tools


display_path_in_title_bar_of_xterm_session

Display path in title bar of XTerm session

Handy when you have multiple XTerms open, and need to keep track of where you are when you switch between them.

Edit your .profile (or .bashrc, as the case may be):

vi .profile

Add this if you want to show symbolic directory links in relative form:

case $TERM in
xterm*|rxvt)
PROMPT_COMMAND='echo -ne "\033]0;${USER} ${HOSTNAME}: ${PWD}\007"'
;;
esac

If you’d prefer to see the physical path of a symbolic link, use this instead:

case $TERM in
xterm*|rxvt)
PROMPT_COMMAND='echo -ne "\033]0;${USER} ${HOSTNAME}: $( pwd -P )\007"'
;;
esac

For example, given the following symbolic link:

data -> /cygdrive/c/data

The first version will display it like this:

[user] [host]: ~/[user]/data

…and the second version will display it like this:

[user] [host]: /cygdrive/c/data
display_path_in_title_bar_of_xterm_session.txt · Last modified: 2018/12/31 18:38 by 127.0.0.1