Created
May 6, 2012 09:15
-
-
Save ikikko/2621182 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
SESSION_NAME=tmux-ssh | |
INITIAL_WINDOW_NAME=tmux-ssh-window | |
### セッションの作成 | |
tmux start-server | |
tmux new-session -d -n $INITIAL_WINDOW_NAME -s $SESSION_NAME | |
### 引数で与えられたホストにssh接続 | |
for i in $* | |
do | |
tmux new-window -n $i | |
tmux send-keys "ssh $i" C-m | |
tmux swap-window -d -s $INITIAL_WINDOW_NAME -t $i | |
done | |
### 不要な初期ウィンドウを除去 | |
tmux kill-window -t $INITIAL_WINDOW_NAME | |
tmux select-window -t $1 | |
### 作成されたセッションにアタッチ | |
tmux attach-session -t $SESSION_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment