Add two script to automate tagging mail with notmutch

This commit is contained in:
Jeremy Gardais 2016-01-14 09:43:58 +01:00
parent 05b08f4247
commit 75d5bee8ac
2 changed files with 28 additions and 0 deletions

25
tagmail Executable file
View File

@ -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

3
tagmail2 Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
notmuch search --format=text0 --output=files tag:killed | xargs -0 --no-run-if-empty rm