Skip to content

Instantly share code, notes, and snippets.

@marcosnils marcosnils/tsplit.sh
Last active Jun 19, 2019

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.