Since mutt seems to be all the rage these days at work, I might as well document here a few things about my .muttrc that might be useful to others.

(I recommend that you start off with the Debian or Ubuntu package for mutt since a large chunk of necessary customization work has already been done by the Debian maintainers.)

Here is how I handle two user accounts. Let's start off by listing both of these addresses so that mutt can recognize emails using these as being sent by me:

alternates "(fmarier@gmail\.com)|(francois@debian\.org)"

Now this is to allow me to change the From address within the editor, in case I forgot to set the right one before pressing 'm':

set use_from

Here are the two settings that I'm going to change when switching to a different identity (from address and status bar display).

# default profile
set from="fmarier@gmail.com"
set status_format="-%r-fmarier@gmail.com: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---"

Here are the macros I use to switch from one account to the next (bound to ESC-1 and ESC-2):

macro index \e1 ":set from=fmarier@gmail.com\n:set status_format=\"-%r-fmarier@gmail.com: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---\"\n" "Switch to fmarier@gmail.com"
macro index \e2 ":set from=francois@debian.org\n:set status_format=\"-%r-francois@debian.org: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---\"\n" "Switch to francois@debian.org"

And this is the code that uses these macros to switch to the right identity automatically:

folder-hook =inbox 'push \e1oi'
folder-hook =debian-inbox 'push \e2oi'

(The 'oi' part at the end is there to restore the default sort order.)

Finally, I've got this convenient shortcut which allows me to switch to my inbox quickly and to go from one inbox to the next:

macro index I "c=inbox\n" "Switch to inbox"
folder-hook =inbox 'macro index I "c=debian-inbox\n" "Switch to debian-inbox"'
folder-hook =debian-inbox 'macro index I "c=inbox\n" "Switch to inbox"'

Next up: indexing your emails using mairix.

Nice post :-), this is a problem I was about to attempt to solve :p

Also, definitely keen on hearing about mairix (I've been thinking about a solution to this problem for a little while now ...).

Comment by Martyn Smith