Notes from a Linguistic Mystic

So, this past week, after a hard drive failure, I did something that many of my friends and colleagues find bizarre: I reinstalled mutt, an open-source command-line email client which runs entirely in your terminal window, and set it up for everyday use on my Mac.

In this post, I’ll explain briefly why I did that, how I went about it, and what programs I use along with it.

Why the heck would you use mutt in 2012?

The choice to go from a full-featured, gui-based mail client (like Apple’s Mail.app) to a command-line client is often confusing to people.  Why use something so spartan, so foreign, with so many GUI mail applications out there.  Open source and cross-platform benefits aside, there are many posts around touting the benefits of mutt specifically.  In an effort to explain my personal choices, I’ll explain not what mutt does, but what using mutt gains me over using Apple’s Mail.app:

  1. mutt is customizable.  Don’t like a key-binding?  Change it!  Don’t like the color scheme?  Change it!  Want it to behave differently?  Change it!  You own your mutt config, and it lets you do whatever you want, without the tyranny of a preferences panel restricting what you can change.

  2. mutt is quick.  Opening a message is near-instant on a remote server, and even quicker if you’re hosting email locally.

  3. mutt lets me sit down and write all the email I need without ever needing to use a mouse.  That means that everything’s just a bit quicker, and just a bit more streamlined.  When I’m using mutt to do something familiar, I become the bottleneck in my workflow, not the program or the input.

  4. mutt lets me blast through emails absurdly quickly.  I can clear my inbox in just a few keystrokes, if needed, and filing is just as quick.

  5. mutt has full pgp integration built-in.  Although gpgmail is great and getting better, mutt makes it all the quicker, and frankly, all the slicker.

  6. mutt lets you use whatever editor you’d like (vim, for me).  This means that even while you’re not coding, you’re still learning vim and getting better with the keystrokes.

  7. Threading actually works in mutt, and doesn’t screw with everything like in mail.app

  8. mutt lets you do magical things.

That last one is important.  Let’s say you want to get rid of some cruft in your (8000+ message) trash mailbox, and thus, you want to delete any message from Twitter.  In Mail.app (with Lion), you’d have to Select the Trash mailbox, type “Twitter” into the search bar, go up there, select “From” (so that you’re not deleting messages that mention twitter), Click “Trash” in the menu bar to limit the scope of the search, Select All, then click Erase and wait for Mail to actually do the erasing.

In mutt?  Get into your trash mailbox, then type: T~f twitter [hit enter];d

… and you’re done.  That’s it.  ”T” for tag, “~f” for from, twitter and then [enter] makes the query”;” means “do this to tagged items”, and “d” means “delete”.  If you then wanted to delete anything from John Smith, T~f John Smith [enter];d.  Or to remove any trace of email from your brief membership in the society for the prevention of cruelty to vowels, T savethevowels.org[enter];d.  Using this, I was able to intelligently cull 2000 messages from my trash last night in the span of around 10 minutes.

Another example is “l”, for “limit”.  If I want to find every email I’ve sent to my friend Ian, I would open my sent folder and type l ian"[enter].  Then, I would be limited to seeing only posts to him, instantly.  See?  Magic.

As such, working with mutt is damned quick.  With practice, I’ve found that everything I could do in mail.app I could do faster in mutt, and because there are always more optimizations to be done and keystrokes to be learned, I’m still getting faster.  Whereas with Mail.app, I felt like the program was usually the bottleneck, using mutt, my brain and my typing speed is the bottleneck.  Which is an oddly wonderful feeling.

So, uh, what’s the catch?

Well, a few things.

  1. mutt isn’t pre-installed on OS X, and setting it up (the first time) is a bit of a pain, described below

  2. mutt doesn’t “just work”, and you have to edit actual configuration files to get it working.

  3. Be prepared to spend some quality time with manual pages and online sites to get everything up and running.  There’s no friendly GUI, and to get everything working, expect to take an evening or two with your computer.

  4. It’s a paradigm shift.  Even once you’ve got it working, old habits die hard, and until the keystrokes are muscle-memoried, it’s a struggle at first.

  5. Lots of things don’t work out of the box.  AddressBook contact support requires muttqt, url viewing requires urlview, viewing html mail requires lynx and the creation of a mailcap file.

  6. Inline images don’t show inline.  You have to download and then view them manually.  This is probably the biggest drawback.

  7. You’ll need a separate mail notifier program to let you know when you’ve got new mail without looking at the terminal window, like the now-free Notify

In short, switching to mutt from Mail.app is like switching to vim from something like TextEdit or Notepad.  There’s a learning curve, and it’s not working out of the box.  But if you’re willing to do the learning and put the parts together, it’s a whole bunch faster, as you can tailor it exactly how you want it.  Much like a good vim configuration or a Gentoo linux install, your mutt installation isn’t created, it’s crafted.

Uh… OK.  How do I install it?

Well, first, it’s very possible that a server you love already has mutt installed, so you can try it there before you buy it.  But I’m assuming you’ve started to fall in love and want to install it on your Mac (running 10.7 or 10.8).  Here are the steps I took to get it set up:

  1. Install XCode (from the Mac App Store, free).

  2. Open Xcode preferences-> Downloads-> Components and click “Install” for “command line tools”

  3. Install Homebrew, to make installing all the other tools easier

  4. Open up a terminal once your homebrew install has finished and type:
    • brew install slang urlview lynx
    • brew install mutt –-trash-patch -–with-slang
    • (Note that the above command has you actually use a trashcan rather than deleting messages instantly, and uses slang for better color handling)
  5. Create a .muttrc file in your home directory and edit it to configure mutt (Here’s my .muttrc, for reference)

  6. Create a .mailcap file in your home directory and edit it to configure how different attachments are opened (Here’s my (minimal) .mailcap, for reference, which could easily form the basis of yours)

  7. Now you can just type mutt at a terminal, and mutt will open up!

The above steps will get you working with just homebrew, xcode, and a few text files.  From there, what you do with mutt is your own choice, but I hope that you too, might enjoy the speed, efficiency, and frankly, the magic that mutt has to offer.

More complex configuration

Once you’ve got it working, start reading your mail, and when something doesn’t work quite like you want, start searching around.  For instance, if you want autocomplete,  you’ll set up muttqt, using the instructions on that site.  If you want offline access, you can set up offlineimap (and gain a pretty signifcant speed improvement as well).  urlview can be used to get you viewing URLs more quickly, and before long, you’ll find yourself with a wonderfully optimized .muttrc for you to cherish (and use) forever.  Then, once you’ve installed gpg and configured everything there, you can sign, encrypt, decrypt and verify any email you want, any time you want, with just a few keystrokes.

Then, you might spend some time working on the OS X side.  It’s useful to make a terminal pre-set just for mutt, which is at the proper size and coloration and which, when opened, automatically opens a mutt window.  Then you might make an Applescript to open one of those mutt terminal windows automatically when clicked, which you can then save as an Application and keep in your dock.  Then you can install Notify, and Growl, and get better notification of new mail than even Mail.app offers.

Or maybe you’ve got a server, and you can put your .muttrc directly onto said server and login to mutt any time you’d like using ssh, with your settings just how you like them.

Is mutt for me?

No, probably not.  As the creators of mutt say, “every email client sucks, mutt just sucks less”, and that’s really only true if you’ve already got a good computing background.  If you’re happy with your email client, by god, stick with it.  If you only get a few emails a day, and send even fewer, mutt’s overkill. If you’re scared of the terminal, or of text editors like vim or pico, stay clear.  But if you find yourself drifting from mail software to mail software, in search of that one program that will just get out of your way and let you send mail, well, maybe mutt is for you.

EDIT: lbdb, the old solution for working with address book contacts, seems to be abandoned and no longer updated for new versions of OS X. I’ve edited the article to reflect a better new solution, muttqt.


Have a question, comment, or concern about this post? Contact me!