forked from haqistan/mblaze-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmpane
executable file
·43 lines (36 loc) · 825 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
#!/bin/sh
# 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}
editor_cmd=$(mhdr -h 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=$(mhdr -h MpaneLines "$MBLAZE/profile")
[ -z "$lines" ] && lines=20
tmux split-window ${horiz} -l ${lines} "env EDITOR=$EDITOR mloop ${opts} ${args}"