~/.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 -- Ctrl + t
# Navigate windows -- Ctrl+ h,l
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.
# If Tmux running...
tmux ls > /dev/null 2>&1
TMUX_STATUS=$?
if [ $TMUX_STATUS -eq 0 ]; then
# Create function to get pwd, trim to "basepath/",
# and rename window
basepathTitle () {
getval=$(pwd)
BASEPATH_TITLE=" ${getval##*/}/ "
tmux rename-window "$BASEPATH_TITLE"
}
# Change cd functionality to rename window title to
# pwd after every directory change
cd () {
builtin cd "$@"
CD_STATUS=$?
basepathTitle
return "$CD_STATUS"
}
# Change vim functionality to change title
# back to basepath on close
vim () {
/usr/bin/vim "$@"
VIM_STATUS=$?
basepathTitle
return "$VIM_STATUS"
}
# Set window title when tmux starts
basepathTitle
fi
Source tmux.conf
tmux source-file ~/.tmux.conf
Source .bashrc
. .bashrc