dotfiles/mail/aerc/mail-sync.sh.example

39 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
OFFLINEIMAP=$(pgrep offlineimap)
NOTMUCH=$(pgrep notmuch)
if [ -n "$OFFLINEIMAP" ] || [ -n "$NOTMUCH" ]; then
echo "Already running one instance of offlineimap or notmuch. Exiting..."
exit 0
fi
echo "Deleting messages tagged as *deleted*"
notmuch search --format=text0 --output=files tag:deleted | xargs -0 --no-run-if-empty rm -v
offlineimap -o
notmuch new
# retag all "new" messages "inbox" and "unread"
notmuch tag +inbox +unread -new -- tag:new
# mailing lists
notmuch tag +mailinglist -- to:xmonad@haskell.org
notmuch tag +mailinglist -- to:guile-user@gnu.org
notmuch tag +mailinglist -- to:zsh-users@zsh.org
notmuch tag +mailinglist -- to:qutebrowser@lists.qutebrowser.org
notmuch tag +mailinglist -- to:~rjarry/aerc-discuss@lists.sr.ht
notmuch tag +mailinglist -- from:outgoing@sr.ht
# TODO: Confirm that we need to do this
# move tagged items across folders and retag
notmuch search --output=files tag:trash and not folder:Trash | xargs mv -t /home/adam/Maildir/Trash/cur/
notmuch tag +trash -inbox -sent -archive -junk -drafts -- folder:Trash and not tag:trash
# move unimportant institutional messages to the trash after a couple of days
notmuch tag +trash -inbox -- date:..2d and tag:mailinglist
notmuch tag +trash -inbox -- date:..2d and from:@facebookmail.com
notmuch tag +trash -inbox -- date:..2d and from:noreply@twitch.tv
notmuch tag +trash -inbox -- date:..2d and from:messages-noreply@linkedin.com