X
From Arnout Engelen
Contents |
[edit] Xterm titles
[edit] Manually
You can update xterm titles with:
echo -ne "\e]0;yourtitle\007"
(but remember your bash might be configured to reset it again immediately)
[edit] Automatically when executing commands from bash
You can convince bash to update the title with the current command with:
trap 'echo -en "\e]0;$BASH_COMMAND\007"' DEBUG
(thanks to http://www.davidpashley.com/articles/xterm-titles-with-bash.html )
[edit] Automatically when showing the bash prompt
To show the CWD. There's 2 ways to do this, putting the sequences directly into PS1:
PS1='\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
Or adding a PROMPT_COMMAND:
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
The 'PROMPT_COMMAND' sort of seems neater, but will also be 'trapped' by the 'trap' set above, and thus will trigger a problem because in that case the $BASH_COMMAND contains a \007 character.
The 'PS1' solution seems to cause some trouble when the current directory is a long string and the xterm is not very wide. have to look into that.
