-
-
Save princewang1994/71b0504d8afca879c3157679fcf3fc72 to your computer and use it in GitHub Desktop.
tmux脚本示例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tmux has-session -t ssh | |
if [ $? != 0 ] | |
then | |
tmux new-session -d -s ssh // 后台新建一个session | |
tmux split-window -h // 切割窗口 | |
tmux select-pane -t 0 // 选择0号窗口 | |
tmux send-keys "ssh zcmlc@host" C-m //向选择的窗口发送指令 | |
tmux send-keys "cd /home/zcmlc/go/src/pro" C-m | |
tmux send-keys "ctl tail -f log" C-m | |
tmux split-window -v //多次切割后每个小窗口的编号会变化 | |
tmux select-pane -t 1 | |
tmux send-keys "command" C-m | |
tmux send-keys "cd /home/zcmlc/go/src/zcm_activity" C-m | |
tmux select-pane -t 2 | |
tmux send-keys "mysql -uroot -p123456 --host 192.168.1.221 --sigint-ignore --auto-vertical-output" C-m | |
tmux send-keys "use data" C-m | |
tmux -2 attach-session -t ssh //挂载到之前运行的session上 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment