-
Notifications
You must be signed in to change notification settings - Fork 3
/
Bscan
executable file
·52 lines (43 loc) · 1.55 KB
/
Bscan
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
#!/bin/sh
#
# Bscan -- display count of messages in "bulk" folders
#
# Normally invoked by xlbiff. Not intended for general use.
#
# $Id: Bscan,v 1.5 2003/11/11 20:40:54 esm Exp $
#
# Width of the FOLDER (left hand) side of the box
WIDTH_L=13
# Width of the COUNT (right hand) side. 3 digits is plenty for me.
WIDTH_R=3
# Don't clobber existing context... that makes it impossible for us to
# read messages from the command line.
MHCONTEXT=$HOME/Mail/context.tmp.$$; export MHCONTEXT
# Last top-level dir
last_dir=''
# Find all folders with unseen messages
for i in `flist -all -recurse -sequence unseen -noshowzero -fast`; do
# For a given folder, e.g. M/zaurus/oz...
dir=`expr $i : "\([^/]\+\)"` # Parent directory (M)
folder=`expr $i : "[^/]\+/\(.*\)"` # rest of it (zaurus/oz)
# Extract the number of unseen messages in this folder
count=`flist +$i | sed -e 's/^.* \([0-9]\+\) in seq.*$/\1/'`
# Same parent directory as last time? Omit dir, but indent by same amount
#
# Otherwise, display the
if [ "$last_dir" = "$dir" ]; then # Same parent as last time
printf "%*s " ${#dir} " "
else if [ "$folder" = "" ]; then # Diff, but top-level folder
printf "%s " $dir
else # Diff, 2-or-more-level folder
printf "%s/" $dir
fi
fi
# Show the rest of the folder name, right-padding for alignment. Show
# the unseen message count.
fmt=$(expr $WIDTH_L - ${#dir} - 1)
printf "%-*s%*d\n" "$fmt" "$folder" $WIDTH_R "$count"
# Remember this dir for next time
last_dir=$dir
done
rm -f $MHCONTEXT