-
Notifications
You must be signed in to change notification settings - Fork 0
/
sp.sh
46 lines (42 loc) · 934 Bytes
/
sp.sh
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
sp() {
local SP_VERSION="0.1.0"
if [ $# -lt 2 ]
then
case "$1" in
"-h"|"--help")
cat <<- EOF
Usage:
$0 SPLIT SPLIT ... SPLIT PANE
SPLIT:
three-chars string with direction (v|h) and percentage
PANE:
selected pane at the end of the split
Examples:
$ $0 v20 h50 0
$ $0 v25 h33 h33 0
EOF
return 0
;;
"-v"|"--version")
echo $SP_VERSION
return 0
;;
*)
echo $($0 -h)
return 1
;;
esac
fi
PANESELECT=${@:$#}
for sp in ${@:1:${#}-1}
do
local DIRECTION=${sp:0:1}
if [ $DIRECTION = "h" ]; then
DIRECTION="v"
else
DIRECTION="h"
fi
eval "tmux split-window -${DIRECTION}p ${sp:1:3}"
done
eval "tmux select-pane -t$PANESELECT"
}