dotfiles/scripts/tmux-multi-ssh
2024-04-04 12:51:24 +02:00

32 lines
768 B
Bash
Executable File

#!/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
starttmux() {
if [ -z "$HOSTS" ]; then
echo -n "Please provide of list of hosts separated by spaces [ENTER]: "
read HOSTS
fi
local hosts=( $HOSTS )
local target="ssh-multi ${host[0]}"
tmux new-window -n "${target}" ssh ${hosts[0]}
unset hosts[0];
for i in "${hosts[@]}"; do
tmux split-window -t :"${target}" -h "ssh $i"
tmux select-layout -t :"${target}" tiled > /dev/null
done
tmux select-pane -t 0
tmux set-window-option -t :"${target}" synchronize-panes on > /dev/null
}
HOSTS=${HOSTS:=$*}
starttmux