-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmdisplay
executable file
·63 lines (55 loc) · 872 Bytes
/
mdisplay
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
63
#!/bin/sh
# mdisplay [-nxt] msgno|filename
[ -z "$*" ] && {
echo usage: $(basename $0) [-xtn] [mless_args...]
exit 1
}
# 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
}
args=
use_xterm=0
use_tmux=0
[ -n $TMUX ] && use_tmux=1
[ $use_tmux -eq 0 -a -n $DISPLAY ] && use_xterm=1
for arg in $*; do
case $arg in
-x)
use_xterm=1
use_tmux=0
;;
-t)
use_tmux=1
use_xterm=0
;;
-n)
use_xterm=0
use_tmux=0
;;
*)
collect args $arg
;;
esac
done
fold="$FOLDER"
[ -z "$fold" ] && fold="msg"
title="[$fold #$*]"
if [ $use_xterm -ne 0 ]; then
xterm -geom 80x32 -title "$title" -e "mless $*"
elif [ $use_tmux -ne 0 ]; then
tmux new-window -n "$title" "mless $*"
else
mshow $*
fi