What's the easiest way to permanently delete emails with notmuch?
Archwiki recommends the following snippet:
notmuch search --output=files --format=text0 <search-term> | xargs -r0 rm
You must however put arguments directly after search otherwise it won't work. You most likely will also want to run notmuch new after to refresh the index.
I'm thinking that if you're a zsh user it'll be easiest to write a zle function:
notmuch-rm () {
emulate -L zsh
local words=(${(z)BUFFER})
BUFFER="$words[1,2] --output=files --format=text0 $words[3,-1] | xargs -r0 rm"
}
zle -N notmuch-rm
I wonder if anyone could think of a better way to do it? "Better" as in the least amount of button presses and least amount of maintenance mental overhead. I realize that it may sound silly, but if you have to repeat this action hundred times every day it would be nice to simplify it.