Created
April 9, 2016 10:33
-
-
Save abcang/11bfcff22a0633600aefbb01550b8e38 to your computer and use it in GitHub Desktop.
ssh先の場合tmux自動起動するやつ。.zshrcとかに入れると便利。tmuxをデタッチするとssh終了するか聞かれるので便利
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ssh先の場合tmux自動起動 | |
if [[ -n "${REMOTEHOST}${SSH_CONNECTION}" && -z "$TMUX" && -z "$STY" ]] && type tmux >/dev/null 2>&1; then | |
function confirm { | |
MSG=$1 | |
while : | |
do | |
echo -n "${MSG} [Y/N]: " | |
read ans | |
case $ans in | |
[yY]) return 0 ;; | |
[nN]) return 1 ;; | |
esac | |
done | |
} | |
option="" | |
if tmux has-session && tmux list-sessions; then | |
option="attach" | |
fi | |
tmux $option && confirm "exit?" && exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment