How to set iterm2 tab title to that of a running tmux session name?

Viewed 6945

i know tmux display-message -p '#S' will display the current tmux session name, but i donno how to set the current tmux session name to the iterm2 tab title?

This would really help me to distinguish the various tmux sessions that i am running concurrently and jump to the correct tab rightaway.

4 Answers

My workflow is usually centered around panes, and I don't use tmux, so I used a slight variation of @mislav answer:

set_terminal_tab_title() {
  print -Pn "\e]1;$TABTITLE:q\a"
}

precmd_functions=($precmd_functions set_terminal_tab_title)

I threw that into my zshrc; then, in each pane, I export TABTITLE='FOO'. That way, when I switch panes, I get the title I want on the tab.

Related