Macos – Rename Iterm2 tab from within tmux

iterm2macostmux

I can use the following function to rename a iterm2 tab and that works great.

function rename_tab {
    echo -ne "\033]0;"$@"\007"
}

However, if I run this function while in a tmux session, then nothing happens.

Any idea how to make this work while in tmux? Thanks!

Best Answer

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

Related Question