An alias command creates a correspondence between a short name or
nickname or alias and a long name (optional) and an email address.
alias <nickname> [ <long name> ] <address>
Since the name can consist of several whitespace-separated words, the
last word is considered the address, and it can be optionally enclosed
between angle brackets.
For example: alias mumon My dear pupil Mumon email@example.com
will be parsed in this way:
alias mumon My dear pupil Mumon firstname.lastname@example.org ^ ^ ^ nickname long name email address
The nickname (or alias) will be used to select a corresponding long name
and email address when specifying the To field of an outgoing message,
e.g. when using the function in the browser or index context.
The long name is optional, so you can specify an alias command in this
alias mumon email@example.com ^ ^ nickname email address
The mutt aliases mechanism works in this way: you select an alias record
from the alias menu (see below) or simply typing the nickname in the To:
prompt for an outgoing mail, then mutt will fill the To: header of the
mail in this way:
To: <long name> <email address>
If the alias command doesn't specify a long name, then it will fill the
To: header in this way:
To: <email address>
Aliases management setup
You can keep all your alias commands in your muttrc file, but maybe it's
a good idea to keep them in a separate file. The $alias_file variable
let you define this file. For example:
set alias_file=~/.mutt/aliases # where I keep my aliases
In order to load them with auto-completion you need to source the file
or even better (this works only with variable expansion, available in
mutt >=1.5.12) with:
The $sort_alias variable let you decide how you want to see the
list of aliases sorted, according to aliases or nicknames (set
sort_alias=alias), to addresses (set sort_alias = address) or
unsorted (set sort_alias= unsorted) to keep the same order of the
$alias_format lets you specify the format of the aliases menu
(similar to the $folder_format and $index_format variables).
A reasonable aliases setup could consists of the following lines:
set alias_file= ~/.mutt/aliasesset sort_alias= aliasset reverse_alias=yessource $alias_file
A <tab> pressed when typing the To: field of an outgoing mail will
complete the name with the only completion or will open the alias menu
if there are more than one completions, or none: in the first case only
the possible completions will be displayed, in the second case all the
alias records will be displayed.
If you type a complete nickname in the the To: prompt and then select it
with <enter> then the To: field of the mail will be automatically filled
with the corresponding long name and address in this way:
To: <long name> <email address>
The long name specified in the alias command is what is displayed in the
To field for example as in:
To: My dear pupil Mumon <firstname.lastname@example.org>
that is it uses the following format:
If the long name isn't specified, as in:
alias mumon <email@example.com>
then the To: field will be filled in this way:
To: mumon <firstname.lastname@example.org>
Please note that the auto-completion performed by mutt is always
relative to the nicknames (or alias) defined by all the alias commands.
Thus for example you won't match with the auto-completion the foobar
address while pressing <tab> on the text: "My dear" or "pupil" or
but you'll do on the text: "mumon"
The function <create-alias> normally bound to "a" (pager and index
context), adds an alias entry in the aliases file.
From the aliases menu (or context) you can:
tag an entry (<tag-entry> function, usually bound to "t" or space)
select one or more entries (<select-entry>, usually bound to
<return> or <enter>)
delete an entry (<delete-entry>, usually bound to "d") or undelete
it (<undelete-entry>, bound to "u").
Press "?" in the alias menu to see all the current bindings.
You can delete entries in the aliases menu, but you can't edit them: for
this you need to manually edit the aliases file.
Mutt integration with an external address book program
If you're getting hairy, for example if you want to keep a sort of
address book containing not only the information the mutt aliases file
let you track, you can use mutt in combination with an external contact
bookkeeper program like abook or ximian evolution.
For example you might get bored to have to keep the email addresses and
other contacts information (e.g. telephone numbers, sip addresses,
geographical addresses) duplicated in different record formats, and have
to manually and painfully synchronize them.
For this reason mutt has a mechanism that lets you integrate mutt with
an external address book program using a simple mechanism (easily
implemented with some scripting).
Keep in mind that such a system will be completely orthogonal to the
mutt aliases system, and the native auto-completion system will continue
to work with the native aliases system.
In order to integrate mutt with an external program you need to define
the $query_command variable (a more meaningful name could be:
It is the program executed when calling the function <query> and
<complete-query>, that has to take as argument a string, representing
the search string, and has to print a textual output consisting of lines
of the format: