Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Sunday, March 9, 2008

Getting GNU screen to show the current directory or command as the tab title

Put the following in your .bashrc:
#if in screen, update session stuff
if [[ $TERM == 'screen' ]]; then
function rename_screen_tab () { echo -ne "\x1bk$@\x1b\\"; return 0; }
trap 'echo -ne "\ek${USER:0:1}@${HOSTNAME:0:1}#$BASH_COMMAND\e\\"' DEBUG
PROMPT_COMMAND='rename_screen_tab ${USER:0:1}@${HOSTNAME:0:1}:${PWD##*/}'
fi

It shortens your user name to one letter, the host you are on to one letter, and the path to the lowest directory.

Example: b@p#vim extract_link