~/.tmux.conf
Allow window titles to be renamed by our .vimrc and .bash_aliases config files below and set the title format to only show the name.
See the tmux man page for more options under "FORMATS" and "Variable name". For example, to keep the index number, you would change the window-status-format and window-status-current-format lines to "#I:#W".
set -g allow-rename on
set-window-option -g window-status-format "#W"
set-window-option -g window-status-current-format "#W"
Specific to a configuration without index numbers, you can set your tab creation and movement bindings to be more browser- and Vim-like.
# Create window
# Navigate windows
bind -n C-t new-window
bind -n C-h previous-window
bind -n C-l next-window
~/.vimrc
Set the window title to the filename when entering Vim and saving a file.
if exists('$TMUX')
autocmd VimEnter,BufWrite * call system("tmux rename-window ' " . expand("%:t") . " '")
endif
~/.bash_aliases
I used bash instead of the automatic-rename options in tmux so that the window title would be renamed to the active pane, if applicable. I also rename titles back to the basepath on exiting Vim here.
tmux ls > /dev/null 2>&1
TMUX_STATUS=$?
if [ $TMUX_STATUS -eq 0 ]; then
basepathTitle () {
getval=$(pwd)
BASEPATH_TITLE=" ${getval##*/}/ "
tmux rename-window "$BASEPATH_TITLE"
}
cd () {
builtin cd "$@"
CD_STATUS=$?
basepathTitle
return "$CD_STATUS"
}
vim () {
/usr/bin/vim "$@"
VIM_STATUS=$?
basepathTitle
return "$VIM_STATUS"
}
basepathTitle
fi
Source tmux.conf
tmux source-file ~/.tmux.conf
Source .bashrc
. .bashrc