function on_exit(){
printf "\033kbash\033\\"
tmux set-window-option automatic-rename on >/dev/null 2>&1
trap - SIGINT SIGTERM
}
function ssh() {
if [ $TERM = "screen" ];then
trap on_exit SIGINT SIGTERM
a=${1##*@};
printf "\033k$a\033\\"
/usr/bin/ssh $@
printf "\033kbash\033\\"
else
/usr/bin/ssh $@
fi
tmux set-window-option automatic-rename on >/dev/null 2>&1
}
关于 tmux 的窗口名字设置,man tmux 搜索 “NAMES AND TITLES” 有详细信息。trap 函数是为了 Ctrl-C 或者 ssh 推出的时候重置 tmux 窗口名字。
没有评论:
发表评论