-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathminbox
executable file
·49 lines (44 loc) · 1.11 KB
/
minbox
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
#!/bin/ksh
# minbox - list some inbox
MBLAZE=${MBLAZE-$HOME/.mblaze}
cfglook () {
mhdr -h $* | envsubst
}
basedir=$(cfglook MaildirBase "$MBLAZE/profile")
basedir=${basedir-$HOME/Maildir}
inbox_name=$(cfglook InboxName "$MBLAZE/profile")
[ -z "${inbox_name}" ] && inbox_name=INBOX
inbox=$(cfglook Inbox "$MBLAZE/profile")
[ -z "${inbox}" ] && inbox=${basedir}/${inbox_name}
scanner=mscan
sequence="mseq -S"
[ -n "$MB_PURTY" ] && {
sequence=mseq
scanner="mapply msummary"
}
threader=mthread
verbose=0
while [ $# -ne 0 ]; do
case "$1" in
-v) verbose=$(expr 1 + $verbose); shift ;;
-t) threader=cat; shift ;;
*) break ;;
esac
done
if [ $# -gt 0 ]; then
inbox="${basedir}/$1"
shift
fi
mlist_args="$*"
filter=cat
if [ -n "$MB_HEAD" ]; then
filter="head -$MB_HEAD"
elif [ -n "$MB_TAIL" ]; then
filter="tail $MB_TAIL"
elif [ -n "$MB_MID" ]; then
sedexp=$(echo $MB_MID | sed -e 's/-/,/')
filter="sed -n -e ${sedexp}p"
fi
[ $verbose -ne 0 ] &&
echo ">> mlist ${mlist_args} ${inbox} | ${filter} | ${threader} | ${sequence} | ${scanner}" 1>&2
mlist ${mlist_args} ${inbox} | ${filter} | ${threader} | ${sequence} | ${scanner}