I want my window title bar to show my PWD. In my .bashrc I have this which seems to do the trick for Bash:
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
However, when I use Tmux, the window shows the directory of wherever I launched Tmux, not the current directory I've navigated to within Tmux.
Below, I launched Tmux in ~, then navigate to ~/Downloads. The title bar still shows ~. Behind it is a window where I navigate to ~/Downloads using just Bash; it shows what I want:

Here are things I already tried that did not work:
I guess when I tried this before it was in combination with some other changes... now it works:
in ~/.tmux.conf:
set -g set-titles on
set -g set-titles-string '#T'
in ~/.bashrc (by the way I added |screen to the switch statment):
if [ "$color_prompt" = yes ]; then
PS1='> '
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*|screen)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With