jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

commit e4be391b59b6bd72629ee2bc1275ef3aff1a4b61
parent adcfe5e7b802cb0290d77b8d82cc3b6317c17817
Author: Jaromil <jaromil@dyne.org>
Date:   Tue,  3 Jul 2012 11:24:46 +0200

better stats with proportional occupation ascii bar

Diffstat:
Msrc/zlibs/stats | 40+++++++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/src/zlibs/stats b/src/zlibs/stats @@ -33,24 +33,42 @@ stats() { weeks) weeks ;; *) # simple stats - typeset -alU ml + typeset -al tot + typeset -alU fold list_maildirs oldpfx="" grandtot=0 for i in ${maildirs}; do + # find maildir prefixes pfx=`echo $i | cut -d. -f1` - if [ "$pfx" = "$oldpfx" ]; then continue - else oldpfx=$pfx; fi - tot=`find $MAILDIRS/$pfx* -type f | wc -l` - { test $tot -gt 0 } && { - ml+=("$tot\t:: $pfx") - grandtot=$(( $grandtot + $tot )) - } + # is it a new prefix? + { test "$pfx" = "$oldpfx" } && { continue } + oldpfx=$pfx + + fold+=($pfx) + # how big? + tot+=("`find $MAILDIRS/$pfx* -type f | wc -l`") + grandtot="$(( $grandtot + ${tot[${#tot}]} ))" + done + # calculate screen size and bigger tot + maxtot=0 + for x in $tot; do # find max + if [ $x -gt $maxtot ]; then + maxtot=$x; fi done - for m in ${(O)ml}; do - print " ${m}" + + c=0 + for f in ${fold}; do + c=$(( $c + 1 )) + sbar="" + # Euclides: cols : x = maxtot : tot + cols=$(( $COLUMNS - 20 )) + bar=$(( $cols * ${tot[$c]} )) + bar=$(( $bar / $maxtot )) + for b in {0..$bar}; do sbar="${sbar}#"; done + print " ${tot[$c]}\t$sbar ${fold[$c]}" done - notice "Total maildirs: ${#ml}" + notice "Total maildirs: ${#fold}" act "Total e-mails stored: ${grandtot}" act "Storage occupation: `du -hs $MAILDIRS | awk '{print $1}'`" ;;