Auto tmux ssh hostname window title that actually works
Working a lot with tmux? Lost in window list?
This very simple ssh wrapper that will automatically set your current tmux window title to the hostname that you’ve sshed on.
[code language=”shell”]
ssh() {
tmux rename-window “$*”
command ssh “$@”
echo “Counting to 60”
sleep 60 && exit
tmux rename-window “bash (exited ssh)”
}
[/code]
Add it to your ~/.zshrc or ~/.bashrc or any other environment file that is executed automatically and it will wrap your “ssh” command to a function that intercepts hostname that you ssh and will set you current tmux window name so it looks like this:
* all those positions are hostnames except for window 0