Skip to content

Instantly share code, notes, and snippets.

@wush978
Last active May 25, 2016 06:40
Show Gist options
  • Select an option

  • Save wush978/7d74bf6584730888b778f596ff6f6a4d to your computer and use it in GitHub Desktop.

Select an option

Save wush978/7d74bf6584730888b778f596ff6f6a4d to your computer and use it in GitHub Desktop.
#!/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