Posted on Mon 26 September 2016

secrets of mutt

mutt is a mail user agent, like Thunderbird or GMail. Unlike GMail, it is not tied to a specific mail service, and unlike Thunderbird, mutt does not have a graphical point-and-click interface. mutt runs inside a terminal (like xterm, iterm or just about anything that you can use ssh in).

If that was your first introduction to mutt, you should probably look at the main site and read some tutorials before deciding if it will be useful to you. If, on the other hand, you have played around with mutt but not become a complete convert, this entry will hopefully illuminate some of the reasons to use mutt as your primary mail interface.

The most powerful mutt mechanism is the pattern which is a way of specifying what messages you want to see (_l_imit), or do something to (_t_ag).

Suppose you want to see only the messages from your friend Phyllicia, who uses a gmail account and a university account. l~fphyllicia<enter> will limit your view to messages from Phyllicia. (Obvious next question: how do you go back to seeing all the messages in the folder? Limit to “.”, a pattern that matches everything. l. )

Now you want to save all the messages from Phyllicia to their own folder. Tag those messages: T~fphyllicia and then use the semicolon prefix to indicate that your next action applies to all tagged messages: ;s will bring up the save options. Similarly, you can ;d to delete all tagged messages.

You can also hand-tag messages one at a time with t and untag them the same way, or use a pattern to untag messages with <ctrl>t.

An extremely common workflow is to _l_imit your messages to some set that makes sense to you, reply, delete or archive them as appropriate, and then reset the limit back l. to everything. Unless you are very careful with your tagging patterns, it’s a good idea to start by using a limit with that pattern, checking that those are the right messages, and then tagging them — mutt will remember the last pattern that you used and offer it up when you tap T.

Some patterns are useful enough to justify turning them into macros. The .muttrc file happily accepts definitions:

Limit to only new messages: macro index .n "l~N\n"

Limit to messages received in the last day: macro index .t "l~d<1d\n"

Limit to messages received yesterday: macro index .y "l~d<2d ~d>1d\n"

Limit to messages not from my coworkers: macro index .w "l!~fworkplace.com\n"

To use these, I just type .n or .w and so forth.

And this one has become standard for me: folder-hook . push '<limit>((~N|~O)!~D)|(~d<1d!~Q)<enter>'

Each time I change to a new folder, the folder-hook executes and gives me an initial view limited to messages which are New, Old-but-not-read, or are recent and I replied to them. If you can’t bring yourself to adopt Zero Inbox or similar fads, this is a great way of getting a concise overview of what’s important.

Patterns. They’re really the best argument that mutt has.


© -dsr-. Send feedback or comments via email — by continuing to use this site you agree to certain terms and conditions.

Built using Pelican. Derived from the svbhack theme by Giulio Fidente on github.