tmux启动1个窗口,选择启动几个session,每个session平均分4个panel
启动:
#!/usr/bin/env bash
echo "create windows count:"
read winCnt
cmd=$(which tmux) # tmux path
session=work # session name
if [ -z $cmd ]; then
echo "You need to install tmux."
exit 1
fi
$cmd has -t $session
if [ $? != 0 ]; then
#new session, window name is "env"
$cmd new -s $session -d -n window0
for ((i=0; i < winCnt; i++))
do
winName=window$i
echo $winName
if [ $winName != window0 ]; then
#new window "i"
$cmd neww -n $winName -t $session -d
fi
#split window ""
$cmd splitw -v -p 50 -t $winName
$cmd splitw -h -p 50 -t $winName
$cmd selectp -t 0
$cmd splitw -h -p 50 -t $winName
$cmd selectp -t 0
done
#select first window
$cmd selectw -t $session:window0
fi
$cmd att -t $session
exit 0
关闭:
#!/usr/bin/env bash
tmux kill-session -t work
原文地址:https://www.cnblogs.com/zhchy89/p/10058005.html