tmux懶人啟動和關閉腳本
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
tmux懶人啟動和關閉腳本