Last active
May 25, 2016 06:40
-
-
Save wush978/7d74bf6584730888b778f596ff6f6a4d 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 [ $# -ne 1 ]; then | |
| echo 'usage: ./mux.sh [serverlist]' | |
| exit | |
| fi | |
| if [ ! -f $1 ]; then | |
| echo "Serverlist file not found!" | |
| echo 'usage: ./mux.sh [serverlist]' | |
| exit | |
| fi | |
| windowname=$(basename $1) | |
| serverlist=($(cat $1)) | |
| # Create other windows. | |
| tmux new-window -d -n ${windowname} | |
| # Create pane, ssh to server, and set layout | |
| for ((i = 0 ; i < ${#serverlist[@]}-1 ; i++)) | |
| do | |
| tmux send-keys -t ${windowname}.$i ssh\ ${serverlist[$i]} C-m | |
| tmux splitw -t ${windowname} | |
| tmux select-layout -t ${windowname} tiled | |
| done | |
| tmux send-keys -t ${windowname}.$i ssh\ ${serverlist[$i]} C-m | |
| tmux select-pane -t ${windowname}.0 | |
| tmux select-window -t ${windowname} | |
| tmux set-window-option -t ${windowname} synchronize-panes on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment