Tmux window naming

Category: Linux

Tmux and Bash/Zsh config for automatically renaming Tmux window titles

I'm a little OCD about my Tmux window titles (the "tab" labels) and regularly rename them depending on the host I'm on. A simpler way to do this automatically is by adding this line to your .zshrc or .bashrc

printf "\033k`hostname -s`\033\\"

This isn't always convenient as you need to make sure this is present in every host that you login to. A solution for this is to add a Tmux key binding to "send keys" to the host and execute it directly. Put this in your .tmux.conf file

bind-key C-w send-keys 'printf "\033k`hostname -s`\033\\"' Enter

Now you can use your normal Tmux shortcut (you *have* changed it to Ctrl-A, right?), followed by Ctrl-w to rename the window title.

Tuesday April 29, 2014

comments powered by Disqus