Skip to content

Instantly share code, notes, and snippets.

@ckundo
Last active May 28, 2019 12:19
Show Gist options
  • Save ckundo/fb7c23c84cfd911cb958 to your computer and use it in GitHub Desktop.
Save ckundo/fb7c23c84cfd911cb958 to your computer and use it in GitHub Desktop.
Search mail in Mutt with notmuch on OS X

Search mail in Mutt with notmuch on OS X

Install perl

$ brew install perl && brew link perl --force
$ brew install cpanm

Add perl module paths

# .zshrc

# Include ~/.bin in the path
export PATH="$HOME/.bin:/usr/local/bin:$PATH"

# Point perl to local modules
export PERL_LOCAL_LIB_ROOT="$HOME/perl5"
export PERL5LIB="$PERL_LOCAL_LIB_ROOT/lib/perl5"
export PERL_MB_OPT="--install_base \"$PERL_LOCAL_LIB_ROOT\""
export PERL_MM_OPT="INSTALL_BASE=$PERL_LOCAL_LIB_ROOT"
export PATH="$PERL_LOCAL_LIB_ROOT/bin:$PATH";

Install notmuch-mutt script dependencies

cpanm Digest::SHA\
  Mail::Box\
  Mail::Header\
  Mail::Box::Maildir\
  String::ShellQuote\
  Term::ReadLine::Gnu

Fetch notmuch-mutt script and edit for OS X compatability

$ cd ~/.bin && wget http://git.notmuchmail.org/git/notmuch/blob_plain/HEAD:/contrib/notmuch-mutt/notmuch-mutt
$ vi notmuch-mutt
--- a/bin/notmuch-mutt
+++ b/bin/notmuch-mutt
@@ -52,7 +52,7 @@ sub search($$$) {
     empty_maildir($maildir);
     system("notmuch search --output=files $dup_option $query"
 	   . " | sed -e 's: :\\\\ :g'"
-	   . " | xargs -r -I searchoutput ln -s searchoutput $maildir/cur/");
+	   . " | xargs -I searchoutput ln -s searchoutput $maildir/cur/");
 }

 sub prompt($$) {
--
$ chmod +x notmuch-mutt
$ cd ~/.mutt && wget http://git.notmuchmail.org/git/notmuch/blob_plain/HEAD:/contrib/notmuch-mutt/notmuch-mutt.rc
# .mutt/muttrc
source ~/.mutt/notmuch-mutt.rc

Open mutt and open a search with <F8>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment