#+style: #+html: #+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 the =mu-easy= man-page. ** Indexing your mail You can index your mail with: #+begin_src sh $ mu index #+end_src If =mu= did not guess the right Maildir, you can set it explicitly: #+begin_src sh $ mu index --maildir=~/MyMaildir #+end_src 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. *** messages about Helsinki (in message body, subject, sender, ...) #+begin_src sh $ mu find Helsinki #+end_src *** messages to Jack with subject jellyfish containing the word tumbleweed #+begin_src sh $ mu find to:Jack subject:jellyfish tumbleweed #+end_src *** messages between 2 kilobytes and a 2Mb, written in December 2009 with an attachment from Bill #+begin_src sh $ mu find size:2k..2m date:20091201..20093112 flag:attach from:bill #+end_src *** unread messages about soccer or socrates or ... #+begin_src sh $ mu find 'subject:soc*' flag:unread #+end_src ** 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: #+begin_src sh $ mu extract --parts=3,4 my-msg-file #+end_src will get you parts 3 and 4. You can also extract files based on their name: #+begin_src sh $ mu extract my-msg-file '.*\.jpg' #+end_src 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. ** 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: #+begin_src sh $ mu find --fields="'l'" banana | xargs wc -l #+end_src 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|json|sexp)~ may be interesting. ** Integration with mail clients The =mu-find= man page contains examples for =mutt= and =wanderlust=. #+html:
© 2011 Dirk-Jan C. Binnema
#+begin_html #+end_html