-
-
Save bhenderson/e76c43b2925b45eb85ae8c2843bade26 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 into multiple hosts with each in their own tmux pane. | |
if [ "$#" -lt 1 ]; then | |
cat >&2 <<-EOM | |
Usage: $(basename $0) host1 [ host2 ... ] [ -- ssh options ] | |
EOM | |
exit 1 | |
fi | |
hosts=() | |
for opt; do | |
case "$opt" in | |
--) | |
shift | |
break | |
;; | |
*) | |
hosts+=( "$opt" ) | |
shift | |
;; | |
esac | |
done | |
host=${hosts[0]} | |
unset hosts[0] | |
for i in "${hosts[@]}"; do | |
tmux split-window -h ssh "$i" $@ | |
done | |
tmux select-pane -t 0 | |
tmux select-layout tiled | |
tmux set-window-option synchronize-panes on | |
exec ssh "$host" $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I pushed it a little bit further to the following:
https://gist.github.com/svenXY/2e8a7a8d42cc99ada7cf18bdfbaa5ea3