Desktop in a shell: mutt

Continuing my series about a desktop in a shell, today I will present you my mutt setup. I use mutt because it has no bugs and is a really good MUA for people loving consoles ;)

First of all you have to know, that all my mail is forwarded to my server and sorted into Maildirs via maildrop, so I do not care about sorting on my "desktop", which just fetches the mail via IMAP from the server ;)

I'm running mutt-patched from Debian Squeeze, so not all options may be available for you if you do not have the same patchset as I do.

First, tell mutt to fetch mail from via IMAP:

set imap_user=username
set imap_pass=password
set folder="imaps://"
set spoolfile="imaps://"

Now, enable IMAP-IDLE, list subscribed folders, reconnect to the server if needed and mark mail as read when you open it:

set imap_idle
set imap_check_subscribed
unset imap_passive
unset imap_peek

Let mutt save sent mail to the Sent directory on the IMAP server, and postponed mail to Drafts:

set record=+Sent
set postponed=+Drafts

Read mail should stay where it is:

set mbox="!"

We use IMAP-IDLE, thus check for new mail manually only every 90 seconds:

set mail_check=90

Instead timeout after 15 seconds if no user input is given:

set timeout=15

Set default mail from address to my default mail address:


And send mail via mstmp (see below for mstmp configuration):

set sendmail="/usr/bin/msmtp"

Tell mutt which addresses I recieve mail to (danger, ugly regex!):

alternates (evgeni@(|golov.(de|eu))|sargentd@(die-welt|sargentd).net|

As mutt knows where I receive mail, let it set From accordingly:

set reverse_name

Let mutt cache some stuff and find its certificates:

set header_cache="~/.mutt/cache/headers"
set message_cachedir="~/.mutt/cache/bodies"
set certificate_file=~/.mutt/certificates
set ssl_ca_certificates_file=/etc/ssl/certs/ca-certificates.crt

Show only interesting headers in an useful order:

ignore headers *
unignore headers from to subject date cc
hdr_order from to cc subject date

Fix stupid MUAs behaviour (e.g. filenames like =?iso-8859-1?Q?file=5F=E4=5F991116=2Ezip?=):

set rfc2047_parameters

Beep on new mail, will generate a "!" in the window name in screen:

set beep_new

mutt-patched has the great sidebar patch, assign ctrl-n, ctrl-p to select next, prev folder, ctrl-o to open selected folder:

bind index \Cp sidebar-prev
bind index \Cn sidebar-next
bind index \Co sidebar-open

And toggle sidebar visibility with ctrl-b:

macro index \Cb '<enter-command>toggle sidebar_visible<enter><refresh>'
macro pager \Cb '<enter-command>toggle sidebar_visible<enter><redraw-screen>'

Since 1.5.20-2, mutt patched contains my sidebar-dotted and sidebar-sorted patches.

Let mutt shorten the displayed path (e.g. debian-devel instead of and sort the folders (the are returned in random order when using imap_check_subscribed):

set sidebar_shortpath
set sidebar_sort

Now let's set some colors (that match the rest of my "desktop"):

color sidebar_new yellow default
color normal white default
color hdrdefault brightcyan default
color signature green default
color attachment brightyellow default
color quoted green default
color quoted1 white default
color tilde blue default

And add some useful macros for marking new and old messages as read:

macro index .n "<tag-pattern>~N<enter><tag-prefix><clear-flag>N<clear-flag>*" "Catchup all new messages"
macro index .o "<tag-pattern>~O<enter><tag-prefix><clear-flag>O<clear-flag>*" "Catchup all old messages"

When forwarding mail, I like it to be forwarded as an attachment (YMMV):

set mime_forward=yes

I'm using goobook in mutt to fetch my addressbook from Google. As there is no Debian package for goobook (yet), you have to install it yourself (via easy_install):

apt-get install python-argparse python-gdata python-simplejson python-keyring python-nose
easy_install goobook

Configuration is easy via ~/.goobookrc:

# If not given here, email and password is taken from .netrc using
# machine
password: password

And then add the following to your .muttrc:

set query_command="goobook query '%s'"
bind editor  complete-query
macro index,pager a "<pipe-message>goobook add<return>" "add the sender address to Google contacts"

That's all for mutt, but...

We are running mutt in a screen, so let's add the following to .screenrc to fix transparency and cut&paste (see

 defbce on
 term screen-bce

And as mutt uses mstmp (yes, I know, mutt can handle SMTP itself...), this is my .msmtprc:

tls on
auth on
user username
password password
tls_starttls on
tls_certcheck off
# Set a default account
account default :

C'est tout! That is my personal mutt configuration, you can download it as one file here: my .muttrc. And as everyone loves screenshots, here is one:

the default view of my mutt

Oh, the next chapter will be about irssi, but not before next Sunday (March 6th) as I'll be offline for a week, skiing in Austria :)