If you've followed my Mutt posts, you'll know that I'm filtering my mails with
imapfilter and
downloading them with offlineimap.
In this post, I'll share my Mutt configuration. I'm not using Mutt directly, but
mutt-kz which is a fork with good notmuch integration. For this post, it won't
change anything.
Configuration
The complete configuration is made in the .muttrc file. Mutt configuration
supports the source command so that you can put some of your settings in another
files and source them from the .muttrc file. You'll see that the configuration
can soon grow large and therefore, splitting it in several files will save you a
lot of maintenance issues ;)
First, let's tell Mutt who we are:
set from = "[email protected]"
set realname = "Baptiste Wicht"
Receive mail
As I'm using offlineimap to get my mails, there is no IMAP settings in my
configuration. But you need to tell Mutt where the mails are:
set folder = /data/oi/
set spoolfile = "+Gmail/INBOX"
set postponed = "+Gmail/drafts"
source ~/.mutt/mailboxes
The spoolfile and postponed are specifying the inbox and draft mailboxes. The
.mutt/mailboxes file is generated by offlineimap.
By default, Mutt will ask you to move read messages from INBOX to another
mailbox (set by mbox). I personally let my read messages in my inbox and move
them myself in a folder. For that, you have to disable the move:
set move = no
If you move a mail from a mailbox to another, Mutt will ask for confirmation,
you can disable this confirmation:
set confirmappend = no
If you use Mutt, you want to read plaintext messages rather than monstruous
HTML. You can tell Mutt to always open text plain if any:
alternative_order text/plain text/html
If the mail has no text/plain part, you can manage to read HTML in Mutt in an
almost sane format. First, you need to tell Mutt to open html messages:
auto_view text/html
And then, you need to tell it how to open it. Mutt reads a mailcap file to know
how to open content. You can tell Mutt where it is:
set mailcap_path = ~/.mailcap
And then, you have to edit the .mailcap file:
text/html; w3m -I %{charset} -T text/html; copiousoutput;
That will use w3m to output the message inside Mutt. It works quite well. You
can also use linx if you prefer.
Send mail
You need to indicate Mutt how to send mail:
set smtp_url = "smtp://[email protected]:587/"
set smtp_pass = "SECRET"
Some people prefer to use another SMTP client instead of Mutt builtin SMTP
support, you can also do that by setting sendmail to the mailer program.
It is generally a good idea to enforce the charset of sent mail:
set send_charset="utf-8"
You can choose another charset if you prefer ;)
You need to configure vim to correctly handle mail editing:
set editor='vim + -c "set textwidth=72" -c "set wrap" -c "set spell spelllang=en"'
It sets the width of the text, enable wrap and configure spelling.
By default, Mutt will ask you if you want to include the body of the message you
reply to in your answer and the reply subject. You can make that faster by using
these two lines:
set include=yes
set fast_reply
Once mail are sent, they are copied in your outgoing mailbox. If you use GMail,
the STMP server already does that for you, therefore you should disable this
behavior:
set copy = no
Appearance
Many things can also be configured in the appearance of Mutt. If you like the
threaded view of GMail, you want to configure Mutt in a similar way:
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
It is not as good as the GMail view, but it does the job :)
You can make reading mail more comfortable using smart wrapping:
set smart_wrap
A mail has many many headers and you don't want to see them all:
ignore *
unignore From To Reply-To Cc Bcc Subject Date Organization X-Label X-Mailer User-Agent
With that, you just configure which headers you're interested in.
If you're using the sidebar patch (and you should be ;), you can configure the
sidebar:
set sidebar_visible = yes
set sidebar_width = 35
set sort_sidebar = desc
color sidebar_new yellow default
It makes the sidebar always visible with a width of 35 and sort the mailboxes.
The last line makes yellow the mailboxes that have unread mails.
The index_format allows you to set what will shown for every mail in the index
view:
set index_format = "%4C %Z %{%b %d} %-15.15L %?M?(#%03M)&(%4l)? %?y?{%.20y}? %?g?{%.20g} ?%s (%c)"
This is a classical example that display the sender, the flags, the date, the
subject, the size of the mail and so on. You will need to look at the Reference to have more information on
what you can do with the format variables. There are plenty of information that
can be shown.
You can also configure the text that is present on the status bar:
set status_chars = " *%A"
set status_format = "───[ Folder: %f ]───[%r%m messages%?n? (%n new)?%?d? (%d to delete)?%?t? (%t tagged)? ]───%>─%?p?( %p postponed )?───"
The example here displays the current folder, the number of mails in it with
some details on deleted and unread mails and finally the number of postponed
mail. Again, if you want more information, you can read the reference.
You can configure Mutt so that the index view is always visible when you read
mails. For instance, to always show 8 mails in the index:
set pager_index_lines=8
Another important thing you can configure is the colors of Mutt. I'm not gonna
cover everything, since Mutt is very powerful on this part. For instance, here
are some examples from my configuration:
color index red white "~v~(~F)!~N" # collapsed thread with flagged, no unread
color index yellow white "~v~(~F~N)" # collapsed thread with some unread & flagged
color index_subject brightred default "~z >100K"
color header blue default "^(Subject)"
Unless you are really wanting to spend time on this part, I recommend to pick an
existing theme. I took a Solarized theme here. It looks quite good
and works well. There other themes available, you'll surely find the one that
looks best for you.
Bindings
Bindings are always very important. If like me, you're a vim aficionado, you'll
want your Mutt bindings to be as close as possible to vim. The default settings
are quite good, but not always close to vim.
Something that is important to know when you configure Mutt bindings is that
they are relative to the current view open (index, pager,browser,attach, ...).
You can bind a keystroke to a different action in each view. You can also select
several views in which the keystroke is valid.
If you are using the sidebar patch (and again, you should ;) ), you'll want to
configure fast bindings for it. Here are mine:
bind index,pager \Ck sidebar-prev
bind index,pager \Cj sidebar-next
bind index,pager \Cl sidebar-open
bind index,pager \Cn sidebar-scroll-up
bind index,pager \Cv sidebar-scroll-down
bind index,pager \Ct sidebar-toggle
I use Ctrl+j,k to move inside the sidebar. I use Ctrl+l to open a folder and
Ctrl+n,v to scroll up and down. The last one is to toggle between multiple
sidebars for instance if you use notmuch.
I find l very good to open messages in the index too:
bind index l display-message
bind index gg first-entry
bind index G last-entry
bind index h noop # Disable h
gg and G are used to go to the first and last element. Here I disabled h which
had a not often used command.
The pager is the view where you read mail:
bind pager h exit
bind pager gg top
bind pager G bottom
bind pager J next-line
bind pager K previous-line
In this view, I use h to get out of the pager, gg and G as usual. As I always
let the index open, I already use j and k to move in the index, so I chose J and
K to move in the pager.
The browser is the view where you select folders for instance:
bind browser l select-entry
bind browser L view-file
bind browser gg first-entry
bind browser G last-entry
bind browser h exit
Again, I use l and h to go back and forth and gg and G to go first and last. j
and k are already used here to go up and down.
In the attach view:
bind attach h exit
bind attach e edit-type # Edit MIME Types
bind attach l view-attach
I use h to exit and l to view an attachment.
That is it for my bindings, but you configure a lot more of them.
Conclusion
This is the end of this post. I have covered my complete Mutt configuration
here. My .muttrc is available online.
If you have comments on my configuration, you're welcome to let a comment on
this post ;)
In the next blog post about my "Mutt journey", I'll talk about notmuch and this
will likely be the last post on this series.