NOTMUCH-TAG(1)
π NOTMUCH-TAG π
okay bestie, buckle up, we're tagging mail like it's going out of style β¨ this is the manual page for notmuch-tag, part of the notmuch fam.
πΈ NAME πΈ
notmuch-tag β add/remove tags for all messages matching the search terms π·οΈπ
β¨ SYNOPSIS β¨
notmuch tag [options ...] +<tag>|-<tag> [--] <search-term> ...
notmuch tag --batch [--input=<filename>]
π¦ DESCRIPTION π¦
So basically: this adds and/or removes tags on every single message that matches your search terms. Slay.
Wanna know what search syntax you can use in <search-term>? Go look at notmuch-search-terms β it's all there, iykyk. π
Tags with a + in front get added, tags with a - in front get removed. And for each message, the tag changes happen in the exact order they show up on the command line. Order matters, periodt.
Now, how does notmuch know where your search terms start? It's the first argument that starts with neither + nor -. But what if your search term literally starts with a + or -?? π No worries β you're allowed to drop a -- argument in there to separate the tags from the search terms. Iconic.
Also important: notmuch tag updates the maildir flags to match your tag changes if the maildir.synchronize_flags configuration option is enabled. Details over in notmuch-config. π
Supported options for tag include:
--remove-allβ wipe all the tags off every matching message before applying the tag changes from the command line. So basically you're setting each message's tags to just the tags you're adding. And if you're adding nothing? Congrats, those messages end up with zero tags. π--batchβ read a whole pile of tagging operations from a file (stdin by default). This is way more efficient than callingnotmuch tagover and over again. Input format lives in TAG FILE FORMAT down below. π«Ά Warning: this option is not compatible with specifying tagging on the command line.--input=<filename>β read input from the file you name instead of stdin. This one implies--batch. π
π TAG FILE FORMAT π
Your input has to be lines that look like this:
+<tag>|-<tag> [...] [--] <query>
Every line gets interpreted kinda the same way notmuch tag command line arguments do. The delimiter is one or more spaces ' '. π
Any characters in <tag> can be hex-encoded with %NN, where NN is the hexadecimal value of the character. Got a character with a multi-byte UTF-8 encoding? Hex-encode each byte. Any spaces in <tag> must be hex-encoded as %20. And any characters that are not part of <tag> must not be hex-encoded. No cap.
Heads up for the future: tag:"tag with spaces" style quoting may be supported for <tag> someday too. Which is exactly why all double quote characters in <tag> should be hex-encoded. Prep now, thank yourself later. β¨
The <query> should be quoted using Xapian boolean term quoting rules: if a term contains whitespace, or a close paren, or starts with a double quote, it must be enclosed in double quotes (not including any prefix) and double quotes inside the term must be doubled. Examples below, bestie π
Leading and trailing space ' ' gets ignored. Empty lines and lines starting with # get ignored too. π
π EXAMPLE π
Here's a valid input for batch tagging. Note that only the isolated '*' acts as a wildcard. Also note the two different quotings of the tag space in tags:
+winner *
+foo::bar%25 -- (One and Two) or (One and tag:winner)
+found::it -- tag:foo::bar%
# ignore this line and the next
+space%20in%20tags -- Two
# add tag '(tags)', among other stunts.
+crazy{ +(tags) +&are +#possible\ -- tag:"space in tags"
+match*crazy -- tag:crazy{
+some_tag -- id:"this is ""nauty)"""
π SEE ALSO π
notmuchnotmuch-confignotmuch-countnotmuch-dumpnotmuch-hooksnotmuch-insertnotmuch-newnotmuch-replynotmuch-restorenotmuch-searchnotmuch-search-termsnotmuch-show
π AUTHOR π
Carl Worth and many others π«Ά (a whole squad fr fr)
β COPYRIGHT β
2009-2026, Carl Worth and many others
okay that's the whole page, you're officially a tagging girlie now π version 0.40, dated Jan 31, 2026 β go forth and tag, bestie, you've got this πΈπ¦β¨
π¦ where this page comes from
- fedora 44: notmuch 0.40-1.fc44 Β· GPL-3.0-or-later
- fedora 44: notmuch 0.40-1.fc44 Β· GPL-3.0-or-later
- nixos 26.05: notmuch 0.40
- ubuntu resolute: notmuch 0.40-1ubuntu1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms