summaryrefslogtreecommitdiff
path: root/shell-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'shell-scripts')
-rw-r--r--shell-scripts/notmuch-hook13
-rw-r--r--shell-scripts/openfile10
2 files changed, 20 insertions, 3 deletions
diff --git a/shell-scripts/notmuch-hook b/shell-scripts/notmuch-hook
index 268f315..12e2d05 100644
--- a/shell-scripts/notmuch-hook
+++ b/shell-scripts/notmuch-hook
@@ -1,10 +1,17 @@
. <(pass show personal/notmuch)
notmuch new --quiet
-notmuch tag -new +jobs -- from:jobs-listing* or from:jobs-noreply*
-notmuch tag -new +houses -- from:"$MAKELAAR" or thread:"{$MAKELAAR}"
-notmuch tag -new -inbox +dev -- from:/.*github.com/ or thread:"{from:/.*github.com/}"
+notmuch tag -new +unread +jobs -- 'tag:new and (from:jobs-listings* or from:jobs-noreply*)'
+notmuch tag -new +unread +houses -- 'tag:new and (from:"'$MAKELAAR'" or thread:{'$MAKELAAR'})'
+notmuch tag -new -inbox +unread +dev -- 'tag:new and (from:/.*github.com/ or thread:{from:/.*github.com/})'
notmuch tag -new +inbox +unread -- tag:new and path:gmail/Inbox/**
+
+# Gmail + mbsync = a lot of duplicates due to the archive
notmuch tag -new +archive -- 'path:gmail/Archive/** -path:gmail/Inbox/** -path:gmail/[Gmail]/** -path:gmail/FarDrafts/** -path:gmail/Important/** -path:gmail/Sent/**'
+
+# Tag messages with files that were moved to trash in neomutt
notmuch tag --remove-all +trash -- path:gmail/Trash/**
+# Same but with messages with files that were moved to spam
notmuch tag --remove-all +spam -- folder:/Spam/
+# Remove files of messages that were tagged but still have files left behind in the mailbox, should be fine since gmail already keeps a duplicate in the Archive so the message will not be deleted only one file of the message
+notmuch search --output=files -- 'path:gmail/Inbox/** -tag:inbox' | grep Inbox | xargs >/dev/null 2>&1 rm
diff --git a/shell-scripts/openfile b/shell-scripts/openfile
new file mode 100644
index 0000000..0f60b10
--- /dev/null
+++ b/shell-scripts/openfile
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Helps open a file with xdg-open from mutt in a external program without weird side effects.
+tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard/files"
+file="$tempdir/${1##*/}"
+[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open"
+mkdir -p "$tempdir"
+cp -f "$1" "$file"
+$opener "$file" >/dev/null 2>&1
+find "${tempdir:?}" -mtime +1 -type f -delete