-
-
Save qtopie/03d4eae19d9731e249570ef4f2a5c498 to your computer and use it in GitHub Desktop.
Start multiple synchronized SSH connections with Tmux
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 | |
# ssh-multi | |
# D.Kovalov | |
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html | |
# a script to ssh multiple servers over multiple tmux panes | |
HOSTS= | |
read_host() { | |
if [ -z "$HOSTS" ]; then | |
echo -n "Please provide of list of hosts separated by spaces [ENTER]: " | |
read HOSTS | |
fi | |
} | |
start_tmux() { | |
local hosts=( $HOSTS ) | |
read_host | |
tmux new-session -d -n 0 | |
tmux new-window "ssh ${hosts[0]}" | |
unset hosts[0]; | |
tmux set -g pane-border-status top | |
for i in "${hosts[@]}"; do | |
tmux split-window -h "ssh $i" | |
tmux select-layout tiled > /dev/null | |
done | |
tmux select-pane -t 0 | |
tmux set-window-option synchronize-panes on > /dev/null | |
# attach session or create one | |
tmux attach | |
} | |
HOSTS=${HOSTS:=$*} | |
start_tmux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment