The following instructions are how to set things up on Fedora 16. For other platforms please be sure to adjust what needs to be downloaded and/or installed from package repositories to suit your needs.
What You Need To Install
I'm going to to assume that you already have Mutt installed. In addition, you'll need to install the following packages and all of their dependencies:
The Script That Does The Work
You can download the notmuch-mutt script here. On my system I stored it at ~/Documents/notmuch-mutt.pl and refer to it as such in my .muttrc below.
The big hook is to add the following to your .muttrc file. Here is what I added to mine:
### BEGIN NOTMUCH-MUTT SETTINGS
macro index <F8> \
"<enter-command>unset wait_key<enter><shell-escape>~/Documents/mutt-notmuch.pl --prompt search<enter><change-folder-readonly>~/.cache/mutt_results<enter>" \
"search mail (using notmuch)"
macro index <F9> \
"<enter-command>unset wait_key<enter><pipe-message>~/Documents/mutt-notmuch.pl thread<enter><change-folder-readonly>~/.cache/mutt_results<enter><enter-command>set wait_key<enter>" \
"search and reconstruct owning thread (using notmuch)"
With this code you can use F8 to search for messages and F9 to reconstruct the thread for one of the search result messages.
That's it! Now with this setup you can stay in a single terminal to search.