Skip to content

Instantly share code, notes, and snippets.

@afresh1
Last active December 22, 2021 22:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afresh1/005d462515ee27ab301005130fa8d470 to your computer and use it in GitHub Desktop.
Save afresh1/005d462515ee27ab301005130fa8d470 to your computer and use it in GitHub Desktop.
A simple clusterssh clone to ssh into many machines at once in a single tmux session. Use `set synchronize-panes` to send commands to all panes at once.
#!/bin/sh
# tssh -- Andrew Fresh <andrew AT AFresh1.com>
set -e
if [ -z "$*" ]; then
echo "usage: tssh server1 [[[server2] server3] ...]"
exit 2
fi
new=""
next="new-session -d"
for s in "$@"; do
new="$new $next ssh $s ; select-layout tiled ;"
next="split-window"
done
export TMUX_TMPDIR=`mktemp -td tssh-XXXXXXXXX`
[ -z "$TMUX_TMPDIR" ] && exit 1
trap 'rm -rf "$TMUX_TMPDIR"' 0 1 2 15
tmux $new set-option exit-unattached on \; attach-session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment