-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux-dual-play
executable file
·62 lines (54 loc) · 1.33 KB
/
tmux-dual-play
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Basic layout for coding purpose
# It has one main pane suitable for running text editor (i.e. vim)
# and several bottom panes suitable for running test suites or terminal commands
maxPaneHeight=40
defaultTopPaneAmount=1
defaultBottomPaneAmount=1
topPaneAmount=$defaultTopPaneAmount
bottomPaneAmount=$defaultBottomPaneAmount
workingDir=$PWD
function createTmux {
tmux new-session -d -s "$1" -c $4
tmux select-window -t :0
tmux split-window -h -c $4
#preparing top pane
if [ $2 -gt 1 ]; then
for i in `seq 1 $[ $2 - 1 ]`;
do
tmux split-window -t :.$[ i - 1 ] -c $4
tmux resize-pane -t :.$[ i - 1 ] -y $[ maxPaneHeight / $2 ]
echo $[ maxPaneHeight / $2 ]
done
fi
#preparing bottom pane
if [ $3 -gt 1 ]; then
for i in `seq 1 $[ $3 - 1 ]`;
do
tmux split-window -t :.$[ i + $2 - 1 ] -c $4
tmux resize-pane -t :.$[ i + $2 - 1 ] -y $[ maxPaneHeight / $3 ]
done
fi
tmux attach-session -t $1 -c $4
}
# Arguments:
# ------------
# $1 for session name
# $2 for amount of top pane
# $3 for amount of bottom pane
# $4 for working directory
if [ $# -eq 0 ]
then
echo 'session name required!'
else
if ! [ -z $2 ]; then
topPaneAmount=$2
fi
if ! [ -z $3 ]; then
bottomPaneAmount=$3
fi
if ! [ -z $4 ]; then
workingDir=$4
fi
createTmux $1 $topPaneAmount $bottomPaneAmount $workingDir
fi