If you Google for this you’ll find a lot of wrong answers.
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