Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Set tmux pane title to short hostname on ssh connections
ssh() {
if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=)" = "tmux" ]; then
tmux rename-window "$(echo $* | cut -d . -f 1)"
command ssh "$@"
tmux set-window-option automatic-rename "on" 1>/dev/null
command ssh "$@"

Thanks for this! It is unhappy with flags on ssh (like -X) though. I used another trick to get just the last argument:

tmux rename-window "$(echo $* | rev | cut -d ' ' -f1 | rev | cut -d . -f 1)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment