Skip to content

Instantly share code, notes, and snippets.

@marcosnils
Last active June 19, 2019 16:47
Show Gist options
  • Save marcosnils/e209f640e8ecb81871a0eed702e5fe26 to your computer and use it in GitHub Desktop.
Save marcosnils/e209f640e8ecb81871a0eed702e5fe26 to your computer and use it in GitHub Desktop.
#!/bin/bash
# tsplit
# @marcosnils
# 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 "$ARGS" ]; then
echo -n "Please provide of list of arguments separated by spaces [ENTER]: "
read ARGS
fi
local args=( $ARGS )
local target="ssh-multi"
tmux set-option -g remain-on-exit on \; new-window -n "${target}" $COMMAND ${args[0]}
unset args[0];
for i in "${args[@]}"; do
tmux split-window -t :"${target}" $COMMAND $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
tmux set-option -g remain-on-exit off
}
COMMAND=$1
shift
ARGS=${ARGS:=$*}
starttmux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment