tmux自动化

1
2
3
4
#!/bin/bash

tmux new -s htop \; neww -d 'cd ~/ && htop' \; splitw -d \; selectp -t 1 \; detach
tmux new -s top \; neww -d 'cd ~/ && top' \; splitw -d \; selectp -t 1 \; detach
1
2
3
4
5
6
#!/bin/bash

tmux new -s htop \; \
send-keys -t htop:0 'cd ~/ && htop' C-m \; \
splitw -d \; selectp -t 1 \; \
send-keys -t htop:0.1 'cd ~/ && clear' C-m \; detach
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash

CMDS=( "htop" "top" )
CMDPATH="~"

for cmd in "${CMDS[@]}"
do
tmux new -s $cmd \; \
send-keys -t $cmd:0 'cd '$CMDPATH' && '$cmd C-m \; \
splitw -d \; selectp -t 1 \; \
send-keys -t $cmd:0.1 'cd '$CMDPATH' && clear' C-m \; detach
done
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash

servs = ("cashier" "notify" "magic" "privacy")
rootPath = $GOPATH/src/path-to-serv

for serv in "${servs[@]}"
do
tmux has-session -t $serv
if [ $? = 0]; then
continue
fi

servPath = $rootPath"/"$serv
tmux new -s $serv -n serv \; \
send-keys -t $serv:0 'cd '$servPath' && bee run' \; \
splitw -d \; selectp -t 1 \; \
send-keys -t $serv:0.1 'cd '$servPath C-m \; detach
done
Last Updated 2018-04-25 Wed 22:19.
Render by hexo-renderer-org with Emacs 25.3.2 (Org mode 8.2.10)