<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>duckland.org news (search)</title><link>http://www.duckland.org/</link><description></description><atom:link href="http://www.duckland.org/categories/search.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 10 Jun 2015 05:13:30 GMT</lastBuildDate><generator>http://getnikola.com/</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Search your email!</title><link>http://www.duckland.org/posts/200905search-your-email.html</link><dc:creator>Don Harper</dc:creator><description>&lt;h1&gt;Search your email!&lt;/h1&gt;

&lt;p&gt;One of the features that most of the pretty GUI mailers offer you is the ability to search your email. While this is not a feature I use regularly, it is one which when you need it, you really need it. I have used &lt;a href="http://grepmail.sf.net"&gt;grepmail&lt;/a&gt; in the past, but it slow for me (it scans the mail files every time) and the big thing for me is that is only supports &lt;a href="http://en.wikipedia.org/wiki/Mbox"&gt;mbox&lt;/a&gt; files, and I use &lt;a href="http://en.wikipedia.org/wiki/Maildir"&gt;maildir&lt;/a&gt; since I use &lt;a href="http://software.complete.org/software/projects/show/offlineimap"&gt;offlineimap&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I recently found &lt;a href="http://www.rpcurnow.force9.co.uk/mairix/"&gt;mairix&lt;/a&gt;. While I have not been using it long, so far I am very impressed with it. It uses an index to speed up the search process, and it smartly adds only new or changed files to the index. The first indexing run was only a few seconds on my archive of almost 15,000 mail messages. I have it scheduled to update the index every 15 minutes, and I never notice the load this will put on the system.&lt;/p&gt;

&lt;p&gt;To integrated mairix with mutt, I wrote a quick little script to search from within (or without) mutt:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/bin/bash
#===============================================================================
#
#          FILE:  mailsearch.sh
#
#         USAGE:  ./mailsearch.sh
#
#   DESCRIPTION:  search mail stuff
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR:  Don Harper (), duck@duckland.org
#       COMPANY:  Don Harper
#       VERSION:  1.0
#       CREATED:  05/25/2009 07:03:30 PM CST
#      REVISION:  ---
#===============================================================================

rm -rf $HOME/Maildir/mfolder
echo "       t::word
              Match word in the To: header.
       c::word
              Match word in the Cc: header.
       f::word
              Match word in the From: header.
       s::word
              Match word in the Subject: header.
       m::word
              Match word in the Message-ID: header.
       b::word
              Match word in the message body.
       d::[start-datespec]--[end-datespec]
              Match messages with Date: headers lying in the specific range.
       z::[low-size]--[high-size]
              Match  messages  whose size lies in the specified range.
       n::word
              Match  word  occurring  as the name of an attachment in the mes-
              sage.  Since attachment names  are  usually  long,  this  option
       F::flags
              Match messages with particular  flag  settings.
              s meaning seen,
              r meaning replied
              f meaning flags
              prefixed by a - to negate its sense.

       The a:: search pattern is an abbreviation for tcf:

   Match words
       The word argument to the search strings can take various forms.
       ~word
              Match messages not containing the word.
       word1,word2
              This matches if both the words are matched in the specified message part.
       word1/word2
              This matches if either of the words are matched in the specified message part.
       substring=
              Match any word containing substring as a substring
       substring=N
              Match any word containing substring, allowing up to N errors  in
              the  match.   For example, if N is 1, a single error is allowed,
              where an error can be
       *      a missing letter
       *      an extra letter
       *      a different letter.
       ^substring=
              Match any word containing substring as  a  substring,  with  the
              requirement  that  substring  occurs  at  the  beginning  of the
              matched word.
       d::start-end
              Specify both start and end explicitly
"
echo -n "Enter your search string: "
read string
mairix $string
mutt -f=mfolder
rm -rf $HOME/Maildir/mfolder
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then, I bound this to “S'’ from within mutt:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; macro index,pager S "!mailsearch\n" 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will give me a reminder of the search command, run the search, and then give me the search results in a new mutt session.&lt;/p&gt;</description><category>cli</category><category>email</category><category>search</category><category>software</category><guid>http://www.duckland.org/posts/200905search-your-email.html</guid><pubDate>Mon, 25 May 2009 23:05:00 GMT</pubDate></item></channel></rss>