-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtssh
More file actions
executable file
·33 lines (27 loc) · 973 Bytes
/
tssh
File metadata and controls
executable file
·33 lines (27 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# This script emulates cssh (see http://sourceforge.net/projects/clusterssh/)
# using tmux panes. It must be run from within a tmux session.
# For each host listed on the command line, it splits a pane and connects via
# ssh. The tmux window is left in 'synchronize-panes' mode, which replicates
# input into any pane to all others. I've bound toggling this mode to a key
# (`e') in my tmux.conf:
# bind e set-window-option synchronize-panes
if [ "$#" -lt 1 ]; then
echo "Usage: $(basename $0) hostname [hostname ...]"
exit 1
fi
if [ -z "$TMUX" ]; then
echo "Error: $(basename $0) must be run from within a tmux session."
exit 1
fi
FIRST_HOST="$1"
shift
# Split panes and ssh to remaining hosts
for HOST in "$@"; do
tmux splitw "ssh $HOST"
# change layout each time to keep split pane from getting to small
tmux select-layout tiled
done
tmux set-window-option synchronize-panes on
# And shh to first host in this pane
exec ssh "$FIRST_HOST"