Dealing With Mail in Mutt

by Juliet Kemp

Tip of the Trade: The command-line mail client mutt may be old school, but it features a wide range of keyboard commands that can be used for various useful tasks.

Possibly I'm old school, but I still use the command-line mail client mutt to handle my mail. One of mutt's advantages is the wide range of keyboard commands you can use to do various useful tasks. Here's a selection of the ones I use regularly.

  • T: Toggles the visibility of quoted text (any line beginning >). Useful when people haven't trimmed their quotes.
  • l: The limit command. l WORD will show only messages whose From or Subject lines contain WORD. Regular expressions are accepted, and you type l all to view all messages again. Even more usefully, there's a set of mutt-specific patterns prefixed with ~, including:
    • ~N: All new messages.
    • ~p: All messages addressed directly to you (e.g., not mailing lists).
    • ~F: All flagged messages (flag a message by hitting F when it's highlighted in the message index).
    • ~b WORD: All messages with WORD in the body.
  • T: Tag messages matching a pattern. To mark all new messages as read, use this key sequence:
    T ~N ; N ^T ~T
    This tags all new (~N) messages, toggles the New flag (N) on all tagged messages (;), and then untags (^T) all messages matching the 'tagged' pattern (~T). I use this a lot when looking at folders with auto-saved messages.
  • Finally: Not a keystroke but a setting in your .muttrc. This line:
    save-hook example.co.uk =example
    means that when you save a message with a From line anywhere in example.co.uk, you'll be automatically prompted to save it to the folder 'example'. This can be a big time-saving for regular correspondents. Also check out fcc-hook and fcc-save-hook.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).

Follow ServerWatch on Twitter

This article was originally published on Monday Nov 9th 2009
Mobile Site | Full Site