diff options
-rwxr-xr-x | local/bin/email-unread | 37 |
1 files changed, 37 insertions, 0 deletions
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 |