notmuch: Update hooks
This commit is contained in:
parent
38b02f5680
commit
c130b2a6b6
6 changed files with 63 additions and 2 deletions
|
|
@ -61,6 +61,7 @@ pass = "~"
|
|||
"office/.config/msmtp/config" = { target = "~/.config/msmtp/config", type = "template" }
|
||||
"office/.config/aerc/accounts.conf" = { target = "~/.config/aerc/accounts.conf", type = "template" }
|
||||
"office/.config/aerc/Personal.qmap" = { target = "~/.config/aerc/Personal.qmap", type = "template" }
|
||||
"office/.config/notmuch/default/hooks/post-new" = { target = "~/.config/notmuch/default/hooks/post-new", type = "template" }
|
||||
"office/.config/neomutt/account" = { target = "~/.config/neomutt/account", type = "template" }
|
||||
"office/.config/neomutt/profile.gmail" = { target = "~/.config/neomutt/profile.gmail", type = "template" }
|
||||
"office/.config/neomutt/profile.private" = { target = "~/.config/neomutt/profile.private", type = "template" }
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ mail_personal_password_cmd = ""
|
|||
mail_notmuch_name = ""
|
||||
mail_notmuch_primary_email = ""
|
||||
mail_notmuch_other_email = ""
|
||||
mail_notmuch_hook_labels = [
|
||||
"+list -- from:notifications@github.com"
|
||||
]
|
||||
|
||||
mail_aerc_from_email = ""
|
||||
mail_aerc_aliases_email = ""
|
||||
|
|
|
|||
|
|
@ -97,5 +97,11 @@ application/vnd.oasis.opendocument.text = pandoc -f odt -t plain
|
|||
.filename,~.*.ics = wezterm -e nvim -
|
||||
|
||||
[hooks]
|
||||
mail-deleted = notmuch new
|
||||
mail-added = notmuch new
|
||||
mail-sent = notmuch new
|
||||
flag-changed = notmuch new
|
||||
tag-modified = notmuch new
|
||||
aerc-shutdown = notmuch new
|
||||
|
||||
[templates]
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ other_email=mo82rimu@studserv.uni-leipzig.de;moehme@ruc.dk;
|
|||
# in the mail store.
|
||||
#
|
||||
[new]
|
||||
tags=unread;inbox
|
||||
ignore=.uidvalidity;.mbsyncstate;Trash;Junk
|
||||
tags=unread;inbox;
|
||||
ignore=.uidvalidity;.mbsyncstate;
|
||||
|
||||
# Search configuration
|
||||
#
|
||||
|
|
|
|||
12
office/.config/notmuch/default/hooks/post-new
Executable file
12
office/.config/notmuch/default/hooks/post-new
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
echo "
|
||||
|
||||
-unread -- folder:Trash OR folder:Archive
|
||||
-unread -flagged -todo -- folder:Trash
|
||||
|
||||
{{#each mail_notmuch_hook_labels}}
|
||||
{{this}}
|
||||
{{/each}}
|
||||
" |
|
||||
notmuch tag --batch
|
||||
39
office/.config/notmuch/default/hooks/pre-new
Executable file
39
office/.config/notmuch/default/hooks/pre-new
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env sh
|
||||
# Little script which moves some tags to specific folders.
|
||||
#
|
||||
# These 'folder-tags' (e.g. trash, archive, inbox) are transient tags
|
||||
# which then get removed when the file is in the correct folder.
|
||||
#
|
||||
# So later when trying to find the emails always use the 'folder:< >'
|
||||
# notmuch search, not the 'tag:< >' search - as the tag only signals that
|
||||
# an e-mail is currently still in the 'wrong' folder and a move action
|
||||
# is necessary.
|
||||
|
||||
MAIL_DIR="$MAIL_PATH"
|
||||
MAIL_DIR="${XDG_DOCUMENTS_DIR:-$HOME/documents}/mail"
|
||||
|
||||
# all folders: -archive -drafts +inbox -jobs -junk -receipts -sent -trash
|
||||
|
||||
# idea: archive, inbox, trash, sent -> transient tags
|
||||
# if anything is tagged, it should be moved into the folder and the tag removed.
|
||||
# Transient tags describe the _type_ of a message (essentially its importance to me)
|
||||
#
|
||||
# jobs, junk, receipts -> describe _what_ a message is (topics etc)
|
||||
# -> stable tags, which stay on a message
|
||||
|
||||
move_and_untag() {
|
||||
tag_to_remove=$1 # e.g. trash
|
||||
folder=$2 # e.g. Trash
|
||||
filter="tag:$tag_to_remove not folder:$folder"
|
||||
id_list=$(notmuch search --output=messages --format=text "$filter")
|
||||
# echo "Moving $(notmuch count "$filter") messages to $folder." # TODO: optional loud mode?
|
||||
notmuch search --output=files --format=text0 "$filter" | xargs -0 --no-run-if-empty mv -t "$MAIL_DIR/$folder/new/"
|
||||
if [ "$id_list" != "" ]; then
|
||||
echo "$id_list" | sed -e "s/^/-$tag_to_remove -- /" | notmuch tag --batch
|
||||
fi
|
||||
}
|
||||
|
||||
move_and_untag trash Trash
|
||||
move_and_untag inbox Inbox
|
||||
move_and_untag archive Archive
|
||||
move_and_untag sent Sent
|
||||
Loading…
Add table
Add a link
Reference in a new issue