Created
June 27, 2016 05:41
-
-
Save kurain/a3cffc36c9d63f4b70e34c6e854900e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
if [ -n "$SESSION_NAME" ];then | |
session=$SESSION_NAME | |
else | |
session=multi-ssh-`date +%s` | |
fi | |
window=multi-ssh | |
### tmuxのセッションを作成 | |
tmux new-session -d -n $window -s $session | |
### 各ホストにsshログイン | |
# 最初の1台はsshするだけ | |
tmux send-keys "ssh $1" C-m | |
shift | |
# 残りはpaneを作成してからssh | |
for i in $*;do | |
tmux split-window | |
tmux select-layout tiled | |
tmux send-keys "ssh $i" C-m | |
done | |
### 最初のpaneを選択状態にする | |
tmux select-pane -t 0 | |
### paneの同期モードを設定 | |
tmux set-window-option synchronize-panes on | |
### セッションにアタッチ | |
tmux attach-session -t $session |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment