From 1d379fa7826e21be8005282b275048176d809d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 18 Aug 2016 23:23:15 +0200 Subject: Add email-unread script --- local/bin/email-unread | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 local/bin/email-unread (limited to 'local/bin/email-unread') diff --git a/local/bin/email-unread b/local/bin/email-unread new file mode 100755 index 0000000..0073112 --- /dev/null +++ b/local/bin/email-unread @@ -0,0 +1,37 @@ +#!/bin/bash +EMAIL=~/.mail +IGNORE="(Spam|trash|Important)" + +if [ "$1" == "-s" ]; then + V=n +else + V=y +fi + +for account in $(ls "$EMAIL"); do + cd $EMAIL/$account + COUNT="0" + COUNT=$(find . -name new -type d -print0 | + while read -d $'\0' folder; do + if [ -n "`echo $folder | grep -E $IGNORE`" ]; then + continue + fi + directory=$(echo $folder | sed 's/^\.\///' | sed 's/\/new$//') + count=$(ls "$folder" | wc -l) + if [ "$count" -gt "0" ]; then + if [ $V == 'y' ]; then + echo "$account/$directory: $count" + else + let 'COUNT = COUNT + count' + echo $COUNT + fi + fi + done | tail -1) + if [ -n "$COUNT" ]; then + if [ $V == "n" ]; then + echo "$account:$COUNT" + else + echo $COUNT + fi + fi +done -- cgit v1.2.3