Introduction

In my last article I explained a (very) basic .muttrc file. From Part One you wouldn't think much of Mutt or all the wonderful functions that I waxed so eloquently about. This was intentional. Mutt can be a beast to configure (as some of my readers pointed out). But my philosophy on climbing the steep learning curve is always to start slow and work your way toward complexity. This is a difficult thing for some like me who wants to learn it all NOW. With Mutt this will certainly *not* happen.

But our basic .muttrc file is really only in an embryonic stage. We need to fill it out to give you a taste of how (excuse my excitement) "Really Cool" Mutt can be. So in this article I will expand our .muttrc file to add some much needed functionality. Then I will get to what I think are Mutt's most useful features: folder-hooks, send-hooks, save-hooks and and key bindings/macros.

Errata

Before we get to Part Two, lets get the Part One errata out of the way. I missed some important information that I should have caught. First, the "pop" variables all should have "set" in front of them. D'oh! Second, Mutt will create the default mail directory "Mail" in your home directory. However, it will not create your spoolfile. This is because Mutt assumes your spoolfile (the place your MDA is saving new incoming messages) is already created. I thought I explained it adequately but, upon further review, I didn't. So let me try again.

Mutt is configured to read the mail in your spoolfile. After reading said mail, you can either delete the mail or save it to your "~/Mail" directory for archiving. However, the mailboxes will need to be created to save this mail. Normally Mutt will use the senders username from their email address to name the mailbox and prompt you if it is not already created. In my case I have Procmail move my mail directly in ~/Mail/Inbox (among other places). This, then becomes my default spoolfile. I failed to mention, however, that I had to create the "Inbox", "Unsent", and "Sent" mailboxes with the command touch [mailboxname].Some readers tried to use the example .muttrc from the article and found that it didn't work. This was an oversight on my part for not being more clear. Mea Culpa.

To set or not to set...

Now with that out of the way lets get down to bidness, shall we? First lets get the "unset" type options out of the way. As I mentioned in Part One, I organize my options in "set" and "unset" sections for clarity. This is a personal preference and a quick search of the .muttrc files of other Mutt users (check the link at bottom) will show you this is true.

Unset Options

Here are some of the options I "unset":

unset confirmappend     # Don't ask me if I want to save a message
unset mark_old          # Don't mark unread messages "old"
unset collapse_unread   # If a thread has an unread msg, don't collapse
unset markers           # Don't use "+" to show wrapped lines
unset metoo             # Remove my address when replying
unset suspend           # Don't stop on Ctrl-Z
unset wait_key          # Used for "autoview" see below
unset pager_stop        # Go to next msg at the end of current msg.

Of these options, by far the most annoying for me was the "markers" option. So this had to go. The "metoo" option is nice to have unset; it saves you from getting many duplicate email messages. Again, most options can be "unset" so this is just a sample. Check the .muttrc files of other Mutt'ers and you will see all sorts of different options.

Set Options

Now for the options I have "set":

set use_domain
set resolve
set postpone = ask-yes
set print = ask-yes
set delete = ask-yes
set editor = "vim -T rxvt"
set copy = yes
set nobeep
set tmpdir = /tmp
set history = 20
set nomarkers
set menu_scroll
set quit = yes
set auto_tag
set beep_new
set status_on_top
set mail_check = 5
set delete = ask-yes
set smart_wrap
set tilde
set pager_context = 3
set pager = builtin
set visual = vim
set askcc
set hidden_host
set shell=/bin/bash
set include = yes
set abort_nosubject = no
set mailcap_path = "/home/poppy17/smanuel/.mailcap"
set help = yes
set folder_format = "%2C %3N %2l %-8.8u %-8.8g %8s %d %f"
set print_command = "lpr -Pbw"

Wow. Lots of options aren't there!? Most of them are self explanatory but I will go over the more esoteric ones. use_domain is useful if you send a lot of mail to your own domain name; just type in the recipients username and mutt will tack on the domain name you set with the hostname option. I have askcc set for convenience sake; I never know when I will need to CC an email and this always reminds me. I should explain what the ask-yes and ask-no values mean. Any option of type quadoption can be "ask-yes", "ask-no", "yes" or "no". The "ask-yes/no" means to ask you but with a default answer of either yes or no. So, for the set postpone option I set this to ask-yes because I sometimes hit the "q" key by mistake. Moreover, if I do want to postpone an message I can press "q-enter" quite quickly. set auto_tag will allow you to apply a function in the index menu against all tagged messages. e.g. tag 5 messages from jdoe@foo.com and press the "s" key and voila!, all tagged messages are saved to the same place.

Hooks, Hooks and More Hooks

Now to Send Hooks, Folder Hooks and Save Hooks...

# Send Hooks
send-hook . 'my_hdr From: Steve Manuel '
send-hook @linuxnovice.org 'set signature = ~/.signature'

# Folder Hooks
folder-hook . 'set index_format="%4C %Z %{%b %d} %-15.15F (%4l) %s"'
folder-hook . set sort = threads
folder-hook . set sort_aux = reverse-date-received
folder-hook =Sent set sort_aux = reverse-date-sent
folder-hook =received set sort = from

# Save Hooks
save-hook markml        =People/Markml
save-hook dmb           =People/dmb 
save-hook mbar          =People/mbar

Now, how do these hook things work? First the Send hooks: Send hook actions are based on the recipients address. The first send hooks says that all outgoing msg should have a "From" header added (dot before the pattern means apply this rule to all messages). The second send hook tells mutt to use a certain signature file for any recipient in the linuxnovice.org domain. Image all the fun you can have with this type of send-hook!

Folder hook actions are based on which mailbox you are reading. In my example the first three folder hooks are global; I set the format for all message entries in the index, sort by threads as well as reverse-date-received. I should explain what the index_format really means. This is option uses the "C" printf() style syntax. It really is Greek to me but I was able to use examples from other .muttrc files to get something that I liked. The important part here is the "%-15.15F" section. The capital "F" is defined to be the authors name or recipients name if sent from you. This is more helpful to me than the default. If you have experience with the printf function in "C" you shouldn't have any problem understanding this. If you don't have any experience don't get discouraged; I don't either.

The next two affect different folders. In my sent folder I want to see messages based on when I sent them and in my received folder from whom I received the message. Folder hooks are one of the best features about Mutt. As you can see, I view most of my folders the same way, but with folder hooks I can do "one-off" tweaking where necessary. Very nice!

Save hooks act on the "From:" header of a messages or the "To:" header if you are the author. I use this option when I don't have a Procmail recipe filtering mail from a certain sender. This way I see these messages in my Inbox and when I get done reading them, pressing "s" will have Mutt save message in the mailbox specified by the save hook. Oh, baby oh!

Hmmm.... Macros... Key Bindings...

And finally Macros and Key bindings...

# Key bindings
bind    pager   k   previous-line
bind    pager   j   next-line
bind    index   H   display-toggle-weed 
bind    pager   H   display-toggle-weed

# Show documentation when typing "help" 
macro generic help "!lynx ~/doc/mutt/html/manual.html\n" "Show Mutt documentation"
macro index   help "!lynx ~/doc/mutt/html/manual.html\n" "Show Mutt documentation"
macro pager   help "!lynx ~/doc/mutt/html/manual.html\n" "Show Mutt documentation"
macro pager   A     |'~/LINUX/share/mutt/mail2muttalias.py'\n "Get all aliases from e-mail"

# Macros to invoke a profile
macro   generic D   ":source ~/.muttrc\n" "Load default profile"
macro   index   D   ":source ~/.muttrc\n" "Load default profile"
macro   pager   D   ":source ~/.muttrc\n" "Load default profile"
macro   generic C   ":source ~/.muttrc.alternate\n" "Load alternate profile"
macro   index   C   ":source ~/.muttrc.alternate\n" "Load alternate profile"
macro   pager   C   ":source ~/.muttrc.alternate\n" "Load alternate profile"

Key bindings allow you to assign a key to a particular function. These functions are available for you perusal in the last section of the Mutt manual. In my example, I have replaced the arrow keys with the 'j' and 'k' keys for up/down line movement. This way I can use the finger memory I have learned from Vi. I also bound the 'H' key to toggle the header weeding (for some reason it wasn't bound). For the most part, Mutt comes with a complete set of key bindings. You generally don't need to add any extras.

Macros, on the other hand, come in handy. A macro is a key or key sequence that performs a set of actions. Quite a few "third party" add-on scripts are invoked using macros. To learn how macros work, I played around with binding the word "help" with the action of launching the Mutt manual in Lynx. Also, I use, among others, the mail2muttalias program to extract all email addresses in a message and save them to the alias file. It is invoked using the "A" which runs the Python script mail2muttalias.py.

So there you have it. A quick run-down of some of the more important features of Mutt. It goes without saying that this is not a full description of everything Mutt can do. I do have a family you know. :-) But this should get you started on fleshing out your own .muttrc. In Part three I will try to tackle PGP and any other bits I left out. If you have experience with Mutt and PGP drop me a note with explanations. *Simple* explanations please, I'm sorta slow. Until next time. Happy Mutt'ing!

Links

Links I mentioned in the article: Mutt config samples