Skip to content

Instantly share code, notes, and snippets.

@nailor
Created April 19, 2012 12:45
Show Gist options
  • Save nailor/2420774 to your computer and use it in GitHub Desktop.
Save nailor/2420774 to your computer and use it in GitHub Desktop.
Open ssh connections from stdin to multiple tmux panes
multitmux() {
read first;
tmux -q new-session -d -s $1 "ssh -t $first";
tmux set-option quiet on
tmux -q set-option -t $1 mouse-select-pane on
tmux -q set-window -g -t $1 synchronize-panes on
while read host; do
tmux -q split-window -p 25 -v -t $1 "ssh -t $host" 2>/dev/null;
if [ "$?" == "1" ]; then
# If pane is too small, change layout and retry opening
tmux -q next-layout
tmux -q split-window -p 25 -v -t $1 "ssh -t $host";
fi
tmux -q select-layout -t $1 tiled;
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment