Skip to content

Instantly share code, notes, and snippets.

@kurain
Created June 27, 2016 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurain/a3cffc36c9d63f4b70e34c6e854900e5 to your computer and use it in GitHub Desktop.
Save kurain/a3cffc36c9d63f4b70e34c6e854900e5 to your computer and use it in GitHub Desktop.
#!/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