Terminal Titles for TMUX
The problem
Some of you know, I use TMUX mostly for logging and handling my zsh plugin cLoggy. From time to time I noticed with tenth of terminal tiles open, the contents of my terminals was not always obvious to me.
As soon as you start tmux in your terminal it goes from this:
to Gnome-Terminal
or just freezes with your last path.
There are plenty of tmux native solutions people came up with but none of them truly worked for my scenarios. SSHing to another box would not update the title any more or the title was missing the wanted information about my current path.
Solution
The way I got the stuff working was to use ZSH and Bash functionality in order to update the naming for all panes. You should apply the changes to your config files to all hosts you SSH to as well.
- In your
~/.tmux.conf
file(s)
set-option -g set-titles on
- In your
/etc/profile
(for bash sessions)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
- In your
~/.zshrc
file(s)
precmd() {
echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"
}
You will end up with the following naming scheme:
tmux-session-name:pane-number:current-app - "user@host:path"
There are plenty of other ways you can create this naming scheme but I like it this way.
If you are crazy enough like me you can even nest your tmux sessions and still know what you're looking at ;)
I hope you enjoyed this entry. It will give you more passive control about your lateral situation in tiling window managers! ;)