💾 Archived View for republic.circumlunar.space › users › johngodlee › posts › 2019-01-05-notmuch-mut… captured on 2023-09-08 at 16:21:41. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-04)

-=-=-=-=-=-=-

Using notmuch to search email in Mutt

DATE: 2019-01-05

AUTHOR: John L. Godlee

I found that the inbuilt search facility in my email client, Mutt, was not all that powerful, or at least I didn't have the inclination to learn its ways. But I already know how to use notmuch for indexing and searching email, so I wanted to incorporate it into my Mutt workflow.

I made sure I had notmuch on my computer:

brew install notmuch

NeoMutt is meant to come with notmuch support out of the box, so I didn't need to apply the notmuch-mutt[1] patch. I did use this mutt-notmuch-py script[2] though, which I included in my $PATH by adding it to ~/bin.

1: https://notmuchmail.org/notmuch-mutt/

2: https://github.com/honza/mutt-notmuch-py

Then, I edited my muttrc to include this macro:

# Search using notmuch
macro index \\ "<enter-command>unset wait_key<enter><shell-escape>mutt-notmuch-py ~/.mail/temporary/search<enter><change-folder-readonly>+temporary/search<enter>" "search mail (using notmuch)"

It calls mutt-notmuch-py and puts results based on your query in ~/.mail/temporary/search as a mailbox, then switches to that temporary mailbox.

I also wanted to make search results appear in my sidebar, to be visible until I ran the macro again, so I added it to my sidebar mailbox creation:

# Notmuch search mailbox
mailboxes "+--- search --------"
mailboxes +temporary/search