Skip to content

Instantly share code, notes, and snippets.

@jackiect
Last active March 15, 2020 02:07
Show Gist options
  • Save jackiect/1a18cad0929a2bec1b4eb13c2dc00323 to your computer and use it in GitHub Desktop.
Save jackiect/1a18cad0929a2bec1b4eb13c2dc00323 to your computer and use it in GitHub Desktop.
#!/bin/sh
# ensure tmux window and pane index begin at 1
w=1
tmux new-session -s 'tmux-container' -d 'sh command.sh "w='$w'&p=1" ; sh'
tmux split-window -h 'sh command.sh "w='$w'&p=2" ; sh'
tmux split-window -v 'sh command.sh "w='$w'&p=3" ; sh'
tmux select-pane -t 1
tmux split-window -v 'sh command.sh "w='$w'&p=4" ; sh'
for i in {2..5}
do
tmux new-window -n w-$i -e 'W='$i -d 'sh command.sh "w='$i'&p=1" ; sh'
tmux select-window -t $i
tmux split-window -h 'sh command.sh "w='$i'&p=2" ; sh'
tmux split-window -v 'sh command.sh "w='$i'&p=3" ; sh'
tmux select-pane -t 1
tmux split-window -v 'sh command.sh "w='$i'&p=4" ; sh'
done
tmux -2 attach-session -d
#!/bin/sh
# ensure tmux window and pane index begin at 1
h=0
tmux new-session -s 'tmux-container' -d 'sh command.sh "-h'$h' -p0" ; sh'
tmux split-window -h 'sh command.sh "-h'$h' -p1" ; sh'
h=1
tmux split-window -v 'sh command.sh "-h'$h' -p0" ; sh'
tmux select-pane -t 1
tmux split-window -v 'sh command.sh "-h'$h' -p1" ; sh'
for i in {2..11}
do
ha=$((i*2-2))
hb=$((ha+1))
w="$ha-$hb"
tmux new-window -n w-$w -e 'W='$w -d 'sh command.sh "-h'$ha' -p0" ; sh'
tmux select-window -t $i
tmux split-window -h 'sh command.sh "-h'$ha' -p1" ; sh'
tmux split-window -v 'sh command.sh "-h'$hb' -p0" ; sh'
tmux select-pane -t 1
tmux split-window -v 'sh command.sh "-h'$hb' -p1" ; sh'
done
tmux -2 attach-session -d
#!/bin/sh
set -x
p=$@
url="http://httpbin.org/get?p=$p"
curl -i $url
cmd="cd ~/tmp/tmp && pwd && echo $p && curl -sL '$url'"
ssh chen@localhost "$cmd"
#!/bin/sh
set -x
q=$@
url="http://httpbin.org/get?$q"
curl $url
cmd="cd /tmp && ls && echo $p && curl -sL '$url'"
ssh chen@localhost "$cmd"
@jackiect
Copy link
Author

jackiect commented Mar 14, 2020

warn:

  • should sleep x(usually 1) seconds after tmux split-window
  • -e opt may not valid

@jackiect
Copy link
Author

create or attach session

SESSION="`tmux-s`"
tmux attach -d -t $SESSION || tmux new -s $SESSION

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment