Skip to content

Instantly share code, notes, and snippets.

@florianbeer
Created April 21, 2015 10:47
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save florianbeer/ee02c149a7e25f643491 to your computer and use it in GitHub Desktop.
Save florianbeer/ee02c149a7e25f643491 to your computer and use it in GitHub Desktop.
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
else
command ssh "$@"
fi
}
@nippyin
Copy link

nippyin commented Jun 13, 2021

Could you please share where would I place this code ? I pasted this in my ~/.zshrc file and ssh to a server but I didn't see remote host name anywhere.

Note: I do have ~/.tmux.config file which have few keybindings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment