mikejsavage.co.uk / blog

RSS feed

04 Mar 2019 / Useful tmux window titles

If you Google for this you’ll find a lot of wrong answers. tmux rename-window is useless and will break if you do like sleep 1 and switch windows. Fortunately tmux has an escape sequence you can use too. First you have to enable it in tmux.conf:

set -g allow-rename on

Then to get the current working directory put this in your shell prompt:

echo -en "\ek$cwd\e\\"

And to show vim’s current file you can put this in vimrc:

set title
set titlestring=%t
if !empty( $TMUX )
        set t_ts=^[k
        set t_fs=^[\
endif

^[ is an actual ESC (0x1B) character, which you can type in vim by doing ctrl+v then escape.