Skip to content

Instantly share code, notes, and snippets.

@persson
Created October 4, 2011 04:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save persson/1260906 to your computer and use it in GitHub Desktop.
Save persson/1260906 to your computer and use it in GitHub Desktop.
tmux script to create single local tmux session attached to many remote tmux sessions
#!/bin/sh
#Yes, there is no six
hosts=(pipe1 pipe2 pipe3 pipe4 pipe5 pipe7 pipe8 pipe9)
names=(pipe1 pipe2 pipe3 pipe4 pipe5 pipe7 pipe8 pipe9)
sessions=(1 2 3 4 5 7 8 9)
tmux new-session -d -s pipelines
i=0
while [ $i -lt $((${#hosts[@]})) ];
do
#FIXME: check to see if window exists to avoid tmux warnings when 'reattaching'
tmux new-window -t pipelines:${sessions[$i]} \
-n ${names[$i]} \
"ssh someuser@${hosts[$i]}.somewhere.com -t 'tmux attach-session -t ${USER}-remote || tmux new-session -s ${USER}-remote'"
i=$((i+1))
done
tmux kill-window -t pipelines:0
tmux attach -t pipelines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment