Here is my setup. First, I have the configuration file for Mairix. My mail is in ~/mail/YYYY/MM/mboxfile (where mboxfile has a name based on what mailing list or whatnot it contains). So my .mairixrc looks like:
base=/home/awwaiid/mail mbox=20*... mfolder=search database=/home/awwaiid/.mairix_database
... which is to say, index all of my mail, and when I do a search put the results into the '/home/awwaiid/mail/search' folder. Oh, and store your DB in .mairix_database.
Next, I wrote a script called search-mail, which I'll use as a wrapper to be more mutt friendly. Also it will allow me to switch which mail indexor I use if the need arises. Plus I will probably add features and shortcuts here. Here is search-mail so far:
#!/usr/bin/perl use strict; print "Enter search terms: "; my $search = <STDIN>; chomp $search; system("/usr/bin/mairix $search > /dev/null &");
And yes, I could have done that with a bash script. But what fun is that?
Finally, there is the line that I've added to my .muttrc which lets me do searches from mutt. It is:
macro index \eM "\ <enter-command>unset wait_key\n\ <shell-escape>/home/awwaiid/bin/search-mail\n\ <change-folder-readonly>=search\n\ <enter-command>set wait_key\n\ " "Super Search for messages"
This command is hooked into <esc>M right now, though I'll surely change that to something much easier. It runs mail-search, which prompts for the search terms and then forks the search. Then I am put into the folder in read-only mode so I don't accidentally delete things (though that might not be necessary or good).
Oh yes, and I dropped the simple command "mairix" into my cron to update the index. The thing runs quite fast and is very fun! I should index all my data for quick searching! (Beagle, why must you foresake me?)