-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmpane
executable file
·48 lines (39 loc) · 866 Bytes
/
mpane
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
#!/bin/ksh
# mpane [-nh] [-mloop_options] [cmd_args]
# set MpaneLines in ~/.mblaze/profile to change
# the default size of the pane we create in tmux
MBLAZE=${MBLAZE-${HOME}/.mblaze}
cfglook () {
mhdr -h $* | envsubst
}
editor_cmd=$(cfglook Editor "$MBLAZE/profile")
[ -z "${editor_cmd}" ] && editor_cmd=${EDITOR-${VISUAL-vi}}
EDITOR=${EDITOR-$editor_cmd}
# collect varname ...
collect () {
typeset var val
var=$1
shift
for arg in $*; do
val=$(eval '$'$var)
if [ -z "$val" ]; then
val=$arg
else
val="${val} ${arg}"
fi
eval $var="$val"
done
}
horiz=
args=
opts=
for arg in $*; do
case $arg in
-h) horiz=-h ;;
-*) collect opts ${arg} ;;
*) collect args ${arg} ;;
esac
done
lines=$(cfglook MpaneLines "$MBLAZE/profile")
[ -z "$lines" ] && lines=20
tmux split-window ${horiz} -l ${lines} "env EDITOR=$EDITOR mloop ${opts} ${args}"