WindyOpenWRT/Tmux.sh
2024-08-31 16:57:34 +08:00

33 lines
867 B
Bash

#!/bin/bash
#自动创建和重连Tmux窗口
ScreenName="WindyOpenWRT-Make"
#横向拆分
#tmux split-window -h
#纵向拆分
#tmux split-window -v
#切换窗口
#tmux select-pane -t 0
#发送命令
#tmux send-keys "sleep 1s" C-m
#判断是否在窗口内的办法
if [ "$TERM" == "screen" ] && [ -n "$TMUX" ]; then
screen=`tmux display-message -p "#S"`
echo "已经处于Tmux[$screen]内。"
else
unset screen
tmux list-session | grep -q $ScreenName
if [ $? -eq 1 ]; then
tmux new-session -d -s $ScreenName && \
tmux split-window -h && \
tmux select-pane -t 0 && \
tmux send-keys "./make.sh" C-m && \
tmux select-pane -t 1 && \
tmux send-keys "btop" C-m && \
tmux select-pane -t 0 && \
tmux -1 attach -t $ScreenName
else
tmux -2 attach-session -t $ScreenName
fi
fi