From 75d5bee8ac1ae3773efd8ec8bb1524930b70a998 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Thu, 14 Jan 2016 09:43:58 +0100 Subject: [PATCH] Add two script to automate tagging mail with notmutch --- tagmail | 25 +++++++++++++++++++++++++ tagmail2 | 3 +++ 2 files changed, 28 insertions(+) create mode 100755 tagmail create mode 100755 tagmail2 diff --git a/tagmail b/tagmail new file mode 100755 index 0000000..10c9928 --- /dev/null +++ b/tagmail @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +notmuch new + +folderlist=$(find ~/.mail/ -mindepth 1 -type d -printf '\n%P\n' | grep -v -E 'INBOX|Sent|Drafts|new|cur|tmp|notmuch' | sort) +folders="$(echo "$folderlist" | grep -v '\.') $(echo "$folderlist" | grep '\.')" +mailboxes="mailboxes" + +# Tag by folder +for folder in INBOX Sent Drafts $folders +do + mailboxes="$mailboxes \"+$folder\"" + tags=$(echo "${folder,,}" | tr -c '[[:alnum:]]' ' ' | sed -e 's/^ *//' -e 's/ *$//') + tagstring=+${tags// /" +"} + if [[ $folder != INBOX ]]; then + tagstring="$tagstring -inbox" + fi + #echo $tagstring + + notmuch tag $tagstring folder:"$folder" +done + +echo "$mailboxes" > ~/.mutt/mailboxes + +exit 0 diff --git a/tagmail2 b/tagmail2 new file mode 100755 index 0000000..e7f29d4 --- /dev/null +++ b/tagmail2 @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +notmuch search --format=text0 --output=files tag:killed | xargs -0 --no-run-if-empty rm