Mutt tips & tricks

I’ve been using mutt with offlineimap and msmtp for a while now, and I want to use this post to collect some features and tips that I’ve found myself often searching for.

  1. Finding messages in the current folder
  2. Tagging messages and doing bulk actions
  3. Changing the filename of the PGP signature attachment
  4. “From”-specific signatures

Finding messages in the current folder

The default keybinding for searching the current folder is l. After you’ve entered search/limiting mode, you can use a wide variety of combinations of flags and regular expressions to match messages:

Note that limiting only matches the subject and the sender’s name by default.

Common flags

~N New/unread messages

~F Flagged messages

~B Search the whole message, not only subject and sender’s name

~A All messages (you can also use all)

See the official mutt documentation for a full list of available patterns.

Tagging messages

A common thing to do is to tag/mark all messages meeting certain criterias. This is very easy to do in mutt using the tag-pattern function. By default, this function is bound to T (that’s shift+t). You can then use the same flags and regular expressions as you can when limiting messages.

tag-pattern only selects messages in the current folder/mailbox

After tagging messages, you’ll most likely want to do something with them. This is where the tag-prefix operator comes into play. This operator tells mutt to apply the next operation to all tagged messages. The default keybinding for tag-prefix is ; (semicolon).

Here’s an example of how to tag all unread messages and mark them as read:

T # Invokes the tag-pattern function
~N # Tags all unread messages
; # tag-prefix operator, next operation will be applied to all tagged messages
W # Clear flag
N # Clear the N (unread) flag

Untagging messages

In the beginning I often found myself searching for how to untag messages. It can be done the same as you tag messages, except that you have to use CTRL instead of SHIFT: ^t <pattern>. To untag all messages, type ^t all.

Changing the PGP signature attachment’s filename

When using mutt with PGP, the default filename of the signature attachment is noname. Although this is a commonly used filename, I personally want it to be named signature.asc. To be able to do this, you’ll need to install mutt with the pgp-verbose-mime-patch. I’ve covered how to install mutt on Mac OS X with this patch in the post My mutt setup (dead link, coming soon).

After you’ve installed mutt with this patch, it’s very simple to change the signature attachment’s filename. All you have to do is add the following line to your .muttrc:

set pgp_mime_signature_filename = 'signature.asc'

“From”-specific signatures

I have different email addresses based on what “role” I have. One (with several aliases) is for personal stuff, one is for work related stuff and one is for my freelance company. I’d like mutt to change my signature based on which address I send the email from. This is also fairly easy to accomplish. Just add the following line to .muttrc for each account you would like a specific signature for:

send-hook "~f from@address1.com" 'set signature=~/.mutt/signature_for_address1'

This will tell mutt that “whenever I send a message from from@address1.com, use the signature in the file ~/.mutt/signature_for_address1”.

That’s it for now. I’ll continue to add useful mutt tips to this post.