Rename Iterm2 tab from within tmux
You can use the tmux option set-titles
In my .tmux.conf I have the following line:
set-option -g set-titles on
You will need to restart the tmux server (kill existing sessions) or re-source the file before the change in your config takes effect. You can also run this for an existing session with <prefix>:set-option set-titles on
I could not get the set-titles to work when using the tmux integration in iTerm2 (running with tmux -CC
)
Instead this works just fine
function tabname {
if [ -z $TMUX ] ; then
printf "\e]1;$@\a"
else
tmux rename-window "$@"
fi
}