Table of Contents
While the default configuration (or “preferences”) make
Mutt usable right out of the box, it is often desirable to tailor Mutt
to suit your own tastes. When Mutt is first invoked, it will attempt to
read the “system” configuration file (defaults set by your
local system administrator), unless the “-n” command line option is specified. This
file is typically /usr/local/share/mutt/Muttrc or
/etc/Muttrc. Mutt will next look for a file named
.muttrc in your home directory. If this file does
not exist and your home directory has a subdirectory named
.mutt, Mutt tries to load a file named
.mutt/muttrc. If still not found, Mutt will try
$XDG_CONFIG_HOME/mutt/muttrc.
.muttrc is the file where you will usually place your
commands to configure Mutt.
In addition, Mutt supports version specific configuration files that are
parsed instead of the default files as explained above. For instance,
if your system has a Muttrc-0.88 file in the system
configuration directory, and you are running version 0.88 of Mutt, this
file will be sourced instead of the Muttrc file. The
same is true of the user configuration file, if you have a file
.muttrc-0.88.6 in your home directory, when you run
Mutt version 0.88.6, it will source this file instead of the default
.muttrc file. The version number is the same which
is visible using the “-v” command line switch or using the
show-version key (default: V) from the index menu.
Mutt is highly configurable because it's meant to
be customized to your needs and preferences. However, this
configurability can make it difficult when just getting started. A
few sample muttrc files come with mutt, under
doc/mutt/samples/. Among them, sample.muttrc-starter is a basic example config with a few
suggested settings and pointers to useful programs.
An initialization file consists of a series of commands. Each line of the file may contain one or more commands. When multiple commands are used, they must be separated by a semicolon (“;”).
The hash mark, or pound sign (“#”), is used as a “comment” character. You can use it to annotate your initialization file. All text after the comment character to the end of the line is ignored.
Example 3.2. Commenting configuration files
my_hdr X-Disclaimer: Why are you listening to me? # This is a comment
Single quotes (“'”) and double quotes (“"”) can be used to quote strings which contain spaces or other special characters. The difference between the two types of quotes is similar to that of many popular shell programs, namely that a single quote is used to specify a literal string (one that is not interpreted for shell variables or quoting with a backslash [see next paragraph]), while double quotes indicate a string for which should be evaluated. For example, backticks are evaluated inside of double quotes, but not for single quotes.
“\” quotes the next character, just as in shells such as bash and zsh. For example, if want to put quotes “"” inside of a string, you can use “\” to force the next character to be a literal instead of interpreted character.
“\\” means to insert a literal “\” into the line. “\n” and “\r” have their usual C meanings of linefeed and carriage-return, respectively.
A “\” at the end of a line can be used to split commands over multiple lines as it “escapes” the line end, provided that the split points don't appear in the middle of command names. Lines are first concatenated before interpretation so that a multi-line can be commented by commenting out the first line only.
Example 3.4. Splitting long configuration commands over several lines
set status_format="some very \ long value split \ over several lines"
It is also possible to substitute the output of a Unix command in an initialization file. This is accomplished by enclosing the command in backticks (``). In Example 3.5, “Using external command's output in configuration files”, the output of the Unix command “uname -a” will be substituted before the line is parsed. Since initialization files are line oriented, only the first line of output from the Unix command will be substituted.
Example 3.5. Using external command's output in configuration files
my_hdr X-Operating-System: `uname -a`
To avoid the output of backticks being parsed, place them inside double quotes. In Example 3.6, “Preventing the output of backticks from being parsed”, the output of the gpg decryption is assigned directly to $imap_pass, so that special characters in the password (e.g.“'”, “#”, “$”) are not parsed and interpreted specially by mutt.
Example 3.6. Preventing the output of backticks from being parsed
set imap_pass="`gpg --batch -q --decrypt ~/.mutt/account.gpg`"
Both environment variables and Mutt variables can be accessed by prepending “$” to the name of the variable. For example,
will cause Mutt to save outgoing messages to a folder named
“sent_on_kremvax” if the environment variable
$HOSTNAME is set to “kremvax.” (See
$record for details.)
Mutt expands the variable when it is assigned, not when it is used. If the value of a variable on the right-hand side of an assignment changes after the assignment, the variable on the left-hand side will not be affected.
If $muttlisp_inline_eval is set, an unquoted parenthesis-enclosed expression will be evaluated as MuttLisp. See the Using MuttLisp section for more details.
Example 3.8. Using MuttLisp expresions
set signature = \ (if (equal $my_name "Kevin McCarthy") ~/kevin.sig ~/other.sig)
The commands understood by Mutt are explained in the next paragraphs. For a complete list, see the command reference.
All configuration files are expected to be in the current locale as specified by the $charset variable which doesn't have a default value since it's determined by Mutt at startup. If a configuration file is not encoded in the same character set the $config_charset variable should be used: all lines starting with the next are recoded from $config_charset to $charset.
This mechanism should be avoided if possible as it has the following implications:
These variables should be set early in a configuration file with $charset preceding $config_charset so Mutt knows what character set to convert to.
If $config_charset is set, it should be set in each configuration file because the value is global and not per configuration file.
Because Mutt first recodes a line before it attempts to parse it, a conversion introducing question marks or other characters as part of errors (unconvertable characters, transliteration) may introduce syntax errors or silently change the meaning of certain tokens (e.g. inserting question marks into regular expressions).
Usage:
group [
-group
name
...] {
-rx
expr
... |
-addr
expr
... }ungroup [
-group
name
...] {
*
|
-rx
expr
... |
-addr
expr
... }
Mutt supports grouping addresses logically into named groups. An address
or address pattern can appear in several groups at the same time. These
groups can be used in patterns (for searching, limiting and tagging) and
in hooks by using group patterns. This can be useful to classify mail
and take certain actions depending on in what groups the message is.
For example, the mutt user's mailing list would fit into the categories
“mailing list” and “mutt-related”. Using send-hook, the sender can
be set to a dedicated one for writing mailing list messages, and the
signature could be set to a mutt-related one for writing to a mutt list
— for other lists, the list sender setting still applies but a
different signature can be selected. Or, given a group only containing
recipients known to accept encrypted mail,
“auto-encryption” can be achieved easily.
The group command is used to directly add either
addresses or regular expressions to the specified group or groups. The
different categories of arguments to the group
command can be in any order. The flags -rx and
-addr specify what the following strings (that cannot
begin with a hyphen) should be interpreted as: either a regular
expression or an email address, respectively.
These address groups can also be created implicitly by the alias, lists, subscribe and alternates commands by
specifying the optional -group option. For example,
alternates -group me address1 address2 alternates -group me -group work address3
would create a group named “me” which contains all your addresses and a group named “work” which contains only your work address address3. Besides many other possibilities, this could be used to automatically mark your own messages in a mailing list folder as read or use a special signature for work-related messages.
The ungroup command is used to remove addresses or
regular expressions from the specified group or groups. The syntax is
similar to the group command, however the special
character * can be used to empty a group of all of
its contents. As soon as a group gets empty because all addresses and
regular expressions have been removed, it'll internally be removed, too
(i.e. there cannot be an empty group). When removing regular expressions
from a group, the pattern must be specified exactly as given to the
group command or -group argument.
Usage:
alias [
-group
name
...]
key
address
[
address
...]unalias [
-group
name
...] {
*
|
key
... }
It's usually very cumbersome to remember or type out the address of someone you are communicating with. Mutt allows you to create “aliases” which map a short string to a full address.
If you want to create an alias for more than one address, you must separate the addresses with a comma (“,”).
The optional -group argument to
alias causes the aliased address(es) to be added to
the named group.
To add an alias:
alias muttdude me@cs.hmc.edu (Michael Elkins) alias theguys manny, moe, jack
To remove an alias or aliases (“*” means all aliases):
unalias muttdude unalias *
Unlike other mailers, Mutt doesn't require aliases to be defined in a
special file. The alias command can appear anywhere
in a configuration file, as long as this file is sourced. Consequently, you
can have multiple alias files, or you can have all aliases defined in
your .muttrc.
On the other hand, the <create-alias>
function can use only one file, the one pointed to by the $alias_file variable (which is
~/.muttrc by default). This file is not special
either, in the sense that Mutt will happily append aliases to any file,
but in order for the new aliases to take effect you need to explicitly
source this file too.
Example 3.9. Configuring external alias files
source /usr/local/share/Mutt.aliases source ~/.mail_aliases set alias_file=~/.mail_aliases
To use aliases, you merely use the alias at any place in Mutt where Mutt prompts for addresses, such as the To: or Cc: prompt. You can also enter aliases in your editor at the appropriate headers if you have the $edit_headers variable set.
In addition, at the various address prompts, you can use the tab character to expand a partial alias to the full alias. If there are multiple matches, Mutt will bring up a menu with the matching aliases. In order to be presented with the full list of aliases, you must hit tab without a partial alias, such as at the beginning of the prompt or after a comma denoting multiple addresses.
In the alias menu, you can select as many aliases as you want with the
select-entry key (default: <Return>), and use
the exit key (default: q) to return to the address
prompt.
Usage:
bind
map
key
function
This command allows you to change the default key bindings (operation invoked when pressing a key).
map specifies in which menu the binding belongs. Multiple maps may be specified by separating them with commas (no additional whitespace is allowed). The currently defined maps are: