Question

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: enter image description here

Here are things I already tried that did not work:

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top