#+style: <link rel="stylesheet" type="text/css" href="mu.css"/>
#+html:<a href="index.html"><img src="mu.png" border="0" align="right"/></a>
#+title: Mu Cheatsheet

* Mu Cheatsheet

  Here are some tips for using =mu=. If you want to know more, please refer to the
  =mu= man pages. For a quick warm-up, there's also the =mu-easy= man-page.

** Indexing your mail
#+html:<pre> $ mu index</pre>

If =mu= did not guess the right Maildir, you can set it explicitly:

#+html:<pre> $ mu index --maildir=~/MyMaildir</pre>

*** Excluding directories from indexing

    If you want to exclude certain directories from being indexed (for example,
    directories with spam-messages), put a file called =.noindex= in the directory
    to exlude, and it will be ignored when indexing (including its children)

** Finding messages

   After you have indexed your messages, you can search them. Here are some
   examples. Also note the =--threads= argument to get a threaded display of
   the messages, and =--color= to get colors (both since 0.9.7).

*** messages about Helsinki (in message body, subject, sender, ...)
#+html:<pre> $ mu find Helsinki</pre>

*** messages to Jack with subject jellyfish containing the word tumbleweed
#+html:<pre> $ mu find to:Jack subject:jellyfish tumbleweed</pre>

*** messages between 2 kilobytes and a 2Mb, written in December 2009 with an attachment from Bill
#+html:<pre> $ mu find size:2k..2m date:20091201..20093112 flag:attach from:bill</pre>

*** signed messages about apples *OR* oranges
#+html:<pre>  $ mu find flag:signed apples OR oranges</pre>

*** messages about yoghurt in the Sent Items folder (note the quoting):
#+html:<pre>  $ mu find maildir:'/Sent Items' yoghurt</pre>


*** unread messages about things starting with 'soc' (soccer, society, socrates, ...)
#+html:<pre>  $ mu find 'subject:soc*' flag:unread</pre>

    Note, the '*' only works at the /end/ of a search term, and you need to
    quote it or the shell will interpret it before =mu= sees it.
    (searching using the '*' wildcard is available since mu 0.9.6)

*** finding messages with images as attachment
#+html:<pre>  $ mu find 'mime:image/*' </pre>
	(since mu version 0.9.8)

*** finding messages with 'milk' in one of its text parts (such as text-based attachments):
#+html:<pre>  $ mu find embed:milk </pre>
	(since mu version 0.9.8)

*** finding /all/ your messages
#+html:<pre>  $ mu find ""</pre>
	(since mu version 0.9.7)

** Finding contacts

   Contacts (names + email addresses) are cached separately, and can be
   searched with =mu cfind= (after your messages have been indexed):

*** all contacts with 'john' in either name or e-mail address
#+html:<pre> $ mu cfind john</pre>

    =mu cfind= takes a regular expression for matching.

    You can export the contact information to a number of formats for use in
    e-mail clients. For example:

*** export /all/ your contacts to the =mutt= addressbook format
#+html:<pre> $ mu cfind --format=mutt-alias</pre>

    Other formats are: =plain=, =mutt-ab=, =wl= (Wanderlust), =org-contact=,
    =bbdb= and =csv= (comma-separated values).

** Retrieving attachments from messages

   You can retrieve attachments from messages using =mu extract=, which takes a
   message file as an argument. Without any other arguments, it displays the
   MIME-parts of the message. You can then get specific attachments:

#+html:<pre> $ mu extract --parts=3,4 my-msg-file</pre>

   will get you parts 3 and 4. You can also extract files based on their name:

#+html:<pre> $ mu extract my-msg-file '.*\.jpg'</pre>

   The second argument is a case-insensitive regular expression, and the command
   will extract any files matching the pattern -- in the example, all
   =.jpg=-files.

   Do not confuse the '.*' /regular expression/ in =mu extract= (and =mu cfind=)
   with the '*' /wildcard/ in =mu find=.

** Getting more colorful output

   Some of the =mu= commands, such as =mu find=, =mu cfind= and =mu view=
   support colorized output. By default this is turned off, but you can enable
   it with =--color=, or setting the =MU_COLORS= environment variable to
   non-empty.

#+html:<pre> $ mu find --color capibara</pre>

   (since =mu= version 0.9.6)

** Integration with mail clients

  The =mu-find= man page contains examples for =mutt= and =wanderlust=. And
  since version 0.9.8, =mu= includes its own e-mail client for =emacs=, =mu4e=.

** Viewing specific messages

   You can view message contents with =mu view=; it does not use the database
   and simply takes a message file as it's argument:

#+html:<pre> $ mu view ~/Maildir/inbox/cur/message24</pre>

   You can also use =--color= to get colorized output, and =--summary= to get a
   summary of the message contents instead of the whole thing.

** Further processing of matched messages

  If you need to process the results of your queries with some other program,
  you can return the results as a list of absolute paths to the messages found:

  For example, to get the number of lines in all your messages mentioning
  /banana/, you could use something like:

#+html:<pre> $ mu find --exec='wc -l'</pre>

  Note that we use 'l', so the returned message paths will be quoted. This is
  useful if you have maildirs with spaces in their names.

  For further processing, also the ~--format=(xml|sexp)~ can be useful. For
  example,

#+html:<pre> $ mu find --format=xml pancake</pre>

  will give you a list of pancake-related messages in XML-format.

#+html:<hr/><div align="center">&copy; 2011-2012 Dirk-Jan C. Binnema</div>
#+begin_html
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-578531-1");
pageTracker._trackPageview();
</script>
#+end_html
