Image of the glider from the Game of Life by John Conway
Skip to content

Tab Completing Aliases For Multiple Accounts In Mutt

In mutt, you can setup multiple accounts, and use account hooks (complete with key bindings) to change to those accounts. I have a Gmail account and a work account. In my Gmail account, I use goobook to access my Google Contacts, and I can successfully tab-complete the addresses when composing mail. But, I have not been able to tab-complete my aliases for my work account. Well, I figured it out, and if this is bothering you, here's the solution:

In my ~/.muttrc:

folder-hook "" "source ~/.mutt/gmail.rc"
folder-hook "" "source ~/.mutt/work.rc"
source ~/.mutt/gmail.rc # open gmail on startup

In my ~/.mutt/gmail.rc:

bind editor <Tab> complete-query
bind editor ^T complete
set query_command = "goobook query '%s'"

In my ~/.mutt/work.rc:

bind editor <Tab> complete        # default Mutt setting
bind editor ^T complete-query     # default Mutt setting
unset query_command               # default Mutt setting
source ~/.mutt/work_aliases

Notice the differences between the key bindings for "complete" and "complete-query" in the different RC files. Also notice that I'm unsetting query_command in my work.rc config. This is necessary to tab-complete the aliases out of the ~/.mutt/work_aliases file (the account details for my Google Account reside in ~/.netrc).

Hope this is helpful to someone else. I'm sure this is only helpful for a very small subset of users, but I wouldn't be doing my due diligence if I didn't post it. is relevant.

{ 5 } Comments

  1. Erik Johnson | November 22, 2011 at 5:59 pm | Permalink

    Looks familiar. Were you in #mutt asking about this yesterday?

  2. Aaron Toponce | November 22, 2011 at 7:53 pm | Permalink

    Yes. I also posted to the mailing list. It's been bugging me for weeks, so I'm excited that I found a solution.

  3. Erik Johnson | November 22, 2011 at 9:34 pm | Permalink

    Cool. I was the guy that was dumbfounded before brendan nudged you in the right direction. So I learned something as well. Thanks for bringing it up.

  4. Steven Harms | March 13, 2012 at 11:54 am | Permalink

    Just used this tip to get things working for me. So, thanks for documenting it here.

  5. Rowan Thorpe | February 17, 2014 at 5:09 am | Permalink

    Heh, I feel privileged to be one of those "people from the future" the xkcd mouseover text is talking about. Thanks for the handy tip.

Post a Comment

Your email is never published nor shared.