Skip to content

Instantly share code, notes, and snippets.

@numa08
Last active December 22, 2015 23:19
Show Gist options
  • Save numa08/6545981 to your computer and use it in GitHub Desktop.
Save numa08/6545981 to your computer and use it in GitHub Desktop.
SSH接続時にリモートホストの名前をペインのタイトルに設定する
# https://www.spatof.org/blog/tmux-ssh-rename-window.html
ssh() {
if [[ $# == 0 || -z $TMUX ]]; then
command ssh $@
fi
local remote=${${(P)#}%.*}
local old_name="$HOST" #現在のペインのタイトルを取得する方法がわかりません>_< しょうがないので、初期値のホスト名を指定
 local renamed=0
if [[ $remote != -* ]]; then
renamed=1
#tmux rename-window $remote
printf '\033]2;%s\033\\' "${remote}"
fi
command ssh $@
if [[ $renamed == 1 ]];then
#tmux rename-window "$old_name"
printf '\033]2;%s\033\\' "${old_name}"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment