Configuration

1. Location of Initialization Files

When NeoMutt starts up it looks for two configuration files – one system file and one user file.

NeoMutt first reads the system configuration file, then the user configuration file. The two files are merged in the sense that "last setting wins". That is, if a setting is defined in both files, the user configuration file's value for that setting is the one that takes precedence and becomes effective.

NeoMutt searches for several different file names when looking for config. It looks for NeoMutt config files before Mutt config files and versioned config before plain config. For example:

Table 3.1. NeoMutt config file search order

neomuttrc
muttrc

This allows the user to create separate NeoMutt and Mutt config files on the same system.

1.1. Location of system config files

NeoMutt will search for a system config file in a neomutt directory in several places. First it searches the locations specified in the XDG_CONFIG_DIRS environment variable, which defaults to /etc/xdg. Next, it looks in /etc. Finally, it tries /usr/share.

The system config file will not be read if the -n option is used on the command line.

NeoMutt will read just one file, the first file it finds, from the list below.

Table 3.2. NeoMutt system config file locations

File Location Notes
/etc/xdg/neomutt/neomuttrc  
/etc/xdg/neomutt/Muttrc Note the case of the filename
/etc/neomuttrc  
/etc/Muttrc Note the case of the filename
/usr/share/neomutt/neomuttrc  
/usr/share/neomutt/Muttrc Note the case of the filename

1.2. Location of user config files

NeoMutt will search for a user config file in several places. First it looks in the directory specified in the XDG_CONFIG_HOME environment variable, which defaults to ~/.config/neomutt. Next, it looks in ~(your home directory). Finally, it tries ~/.neomutt.

You may specify your own location for the user config file using the -F option on the command line.

NeoMutt will read just one file, the first file it finds, from the list below.

Table 3.3. NeoMutt user config file locations

File Location
~/.config/neomutt/neomuttrc
~/.config/neomutt/muttrc
~/.config/mutt/neomuttrc
~/.config/mutt/muttrc
~/.neomutt/neomuttrc
~/.neomutt/muttrc
~/.mutt/neomuttrc
~/.mutt/muttrc
~/.neomuttrc
~/.muttrc

1.3. Config Priority

The majority of NeoMutt's config will be read from two files: the system config in /etc and the user config in, e.g. ~/.neomuttrc

The last file that gets read will overwrite any settings from previous config files. This means that an administrator can set some defaults which the user can override.

Additionally, there are a handful of config items which can be set using an environment variable. They have a lower priority than the NeoMutt config files: $editor, $from, $mailcap_path, $news_server, shell, $spoolfile, $tmpdir, $visual.

Finally, it's possible to set some variables directly on the command-line using the -e option.

Table 3.4. Config Priority

Priority Where Example
Highest Command line neomutt -e 'set from="John Doe <john@example.com>"'
  User Config ~/.neomuttrc
  System Config /etc/neomuttrc
  Environment export EDITOR="/usr/bin/vim"
Lowest Built-in Defaults hard-coded into NeoMutt

2. Starter NeoMuttrc

NeoMutt 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 neomuttrc files come with NeoMutt, under doc/neomutt/samples/. Among them, sample.neomuttrc-starter is a basic example config with a few suggested settings and pointers to useful programs.

3. Syntax of Initialization Files

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 ( ;).

Example 3.1. Multiple configuration commands per line

set realname='John Smith' ; ignore x-

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.

Example 3.3. Escaping quotes in configuration files

set realname="Michael \"MuttDude\" Elkins"

\\ 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"

Note

Using \ at the end of a line only removes the newline character.

Any leading whitespace on the following lines will be part of the configuration.

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 neomutt.

Example 3.6. Preventing the output of backticks from being parsed

set imap_pass="`gpg --batch -q --decrypt ~/.neomutt/account.gpg`"

Both environment variables and NeoMutt variables can be accessed by prepending $ to the name of the variable. For example,

Example 3.7. Using environment variables in configuration files

set record=+sent_on_$HOSTNAME

will cause NeoMutt to save outgoing messages to a folder named sent_on_kremvax if the environment variable $HOSTNAME is set to kremvax.(See $record for details.)

NeoMutt 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.

The commands understood by NeoMutt 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 NeoMutt 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 NeoMutt 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 NeoMutt 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).

4. Address Groups

Usage:

group[ -group name ...] { -rx expr ... | -addr expr ... }
ungroup[ -group name ...] { * | -rx expr ... | -addr expr ... }

NeoMutt 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 NeoMutt user's mailing list would fit into the categories mailing list and NeoMutt-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 NeoMutt-related one for writing to a NeoMutt 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.

5. Defining/Using Aliases

Usage:

alias[ -group name ...] key address [ , address ...] [ # comment ]
unalias[ -group name ...] { * | key ... }

It's usually very cumbersome to remember or type out the address of someone you are communicating with. NeoMutt allows you to create aliases which map a short string to a full address.

Note

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:

# Some aliases, one with a comment
alias alan   Alan Jones <alan@example.com>
alias briony Briony Williams <bw@example.com>
alias jim    James Smith <js@example.com>
# Pointy-haired boss

# An alias that references two other aliases
alias friends alan, briony

To remove an alias or aliases ( * means all aliases):

unalias muttdude
unalias *

Unlike other mailers, NeoMutt 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 .neomuttrc.

On the other hand, the <create-alias> function can use only one file, the one pointed to by the $alias_file variable (which is ~/.neomuttrc by default). This file is not special either, in the sense that NeoMutt 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.8. Configuring external alias files

source /usr/local/share/NeoMutt.aliases
source ~/.mail_aliases
set alias_file=~/.mail_aliases

To use aliases, you merely use the alias at any place in NeoMutt where NeoMutt 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, NeoMutt 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.

6. Changing the Default Key Bindings

Usage:

bind map [ ,map ...] key function
unbind{ * | map | [ ,map ...]} [ key ]

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:

Note

Missing key sequence in unbind command means unibind all bindings in menus given in map .

generic

This is not a real menu, but is used as a fallback for all of the other menus except for the pager and editor modes. If a key is not defined in another menu, NeoMutt will look for a binding to use in this menu. This allows you to bind a key to a certain function in multiple menus instead of having multiple bind statements to accomplish the same task.

alias

The alias menu is the list of your personal aliases as defined in your .neomuttrc. It is the mapping from a short alias name to the full email address(es) of the recipient(s).

attach

The attachment menu is used to access the attachments on received messages.

browser

The browser is used for both browsing the local directory structure, and for listing all of your incoming mailboxes.

editor

The editor is used to allow the user to enter a single line of text, such as the To or Subject prompts in the compose menu.

index

The index is the list of messages contained in a mailbox.

compose

The compose menu is the screen used when sending a new message.

pager

The pager is the mode used to display message/attachment data, and help listings.

pgp

The pgp menu is used to select the OpenPGP keys used to encrypt outgoing messages.

smime

The smime menu is used to select the OpenSSL certificates used to encrypt outgoing messages.

postpone

The postpone menu is similar to the index menu, except is used when recalling a message the user was composing, but saved until later.

query

The query menu is the browser for results returned by $query_command.

mix

The mixmaster screen is used to select remailer options for outgoing messages (if NeoMutt is compiled with Mixmaster support).

key is the key (or key sequence) you wish to bind. To specify a control character, use the sequence \Cx , where x is the letter of the control character (for example, to specify control-A use \Ca). Note that the case of x as well as \C is ignored, so that \CA , \Ca , \cA and \ca are all equivalent. An alternative form is to specify the key as a three digit octal number prefixed with a \(for example \177 is equivalent to \c? ). In addition, key may be a symbolic name as shown in Table 3.5, “Symbolic key names”.

Table 3.5. Symbolic key names

Symbolic name Meaning
\t tab
<tab> tab
<backtab> backtab / shift-tab
\r carriage return
\n newline
\e escape/alt
<esc> escape/alt
<up> up arrow
<down> down arrow
<left> left arrow
<right> right arrow
<pageup> Page Up
<pagedown> Page Down
<backspace> Backspace
<delete> Delete
<insert> Insert
<enter> Enter
<return> Return
<home> Home
<end> End
<space> Space bar
<f1> function key 1
<f10> function key 10

The <what-key>function can be used to explore keycode and symbolic names for other keys on your keyboard. Executing this function will display information about each key pressed, until terminated by ^G.

key does not need to be enclosed in quotes unless it contains a space (  ) or semi-colon ( ;).

function specifies which action to take when key is pressed. For a complete list of functions, see the reference. Note that the bind expects function to be specified without angle brackets.

The special function <noop>unbinds the specified key sequence.

6.1. Warnings about Duplicated Bindings

Due to a limitation of NeoMutt, creating key bindings, or macros, will overwrite existing mappings with similar, shorter, names.

bind index g  group-reply
bind index gg first-entry

In this example, the g binding will be overwritten and cannot be used. Newer versions of NeoMutt will warn the user about this.

To avoid warnings on startup, first set the shorter binding to noop(no operation).

bind index g  noop
bind index gg first-entry

The same is also possible using unbind.

unbind index g
bind index gg first-entry

7. Defining Aliases for Character Sets

Usage:

charset-hook alias charset
iconv-hook charset local-charset

The charset-hook command defines an alias for a character set. This is useful to properly display messages which are tagged with a character set name not known to NeoMutt.

The iconv-hook command defines a system-specific name for a character set. This is helpful when your systems character conversion library insists on using strange, system-specific names for character sets.

8. Setting Variables Based Upon Mailbox

Usage:

folder-hook regex command

It is often desirable to change settings based on which mailbox you are reading. The folder-hook command provides a method by which you can execute any configuration command. regex is a regular expression specifying in which mailboxes to execute command before loading. If a mailbox matches multiple folder-hook s, they are executed in the order given in the .neomuttrc.

The regex parameter has mailbox shortcut expansion performed on the first character. See Mailbox Matching in Hooks for more details.

Note

If you use the ! shortcut for $spoolfile at the beginning of the pattern, you must place it inside of double or single quotes in order to distinguish it from the logical not operator for the expression.

Note

Settings are not restored when you leave the mailbox. For example, a command action to perform is to change the sorting method based upon the mailbox being read:

folder-hook work "set sort=threads"

However, the sorting method is not restored to its previous value when reading a different mailbox. To specify a default command, use the pattern . before other folder-hook s adjusting a value on a per-folder basis because folder-hook s are evaluated in the order given in the configuration file.

Note

The keyboard buffer will not be processed until after all hooks are run; multiple push or exec commands will end up being processed in reverse order.

The following example will set the sort variable to date-sent for all folders but to threads for all folders containing work in their name.

Example 3.9. Setting sort method based on mailbox name

folder-hook . "set sort=date-sent"
folder-hook work "set sort=threads"

9. Keyboard Macros

Usage:

macro menu [ ,menu ...] key sequence [ description ]
unmacro{ * | map | [ ,map ...]} [ key ]

Macros are useful when you would like a single key to perform a series of actions. When you press key in menu menu , NeoMutt will behave as if you had typed sequence . So if you have a common sequence of commands you type, you can create a macro to execute those commands with a single key or fewer keys.

menu is the map which the macro will be bound in. Multiple maps may be specified by separating multiple menu arguments by commas. Whitespace may not be used in between the menu arguments and the commas separating them.

key and sequence are expanded by the same rules as the key bindings with some additions. The first is that control characters in sequence can also be specified as ^x . In order to get a caret ( ^) you need to use ^^ . Secondly, to specify a certain key such as up or to invoke a function directly, you can use the format <key name> and <function name> . For a listing of key names see the section on key bindings. Functions are listed in the reference.

The advantage with using function names directly is that the macros will work regardless of the current key bindings, so they are not dependent on the user having particular key definitions. This makes them more robust and portable, and also facilitates defining of macros in files used by more than one user (e.g., the system neomuttrc).

Optionally you can specify a descriptive text after sequence , which is shown in the help screens if they contain a description.

Note

Macro definitions (if any) listed in the help screen(s), are silently truncated at the screen width, and are not wrapped.

Note

Missing key sequence in unmacro command means unmacro all macros in menus given in menu .

10. Using Color and Mono Video Attributes

Usage:

color[ compose] object [ attribute ...] foreground background
color pattern-object [ attribute ...] foreground background pattern
color regex-object [ attribute ...] foreground background regex
color status[ attribute ...] foreground background [ regex [ num ]]
uncolor[ compose] object
uncolor pattern-object { pattern | * }
uncolor regex-object { regex | * }
uncolor status{ regex | * }

If your terminal supports color, you can spice up NeoMutt by creating your own color scheme.

The types of objects that can be colored fall into two categories: Simple Colors such as the highlight in the index, and Color Lists such as the status bar. These lists can created complexing coloring rules.

10.1. Color Style

Objects in NeoMutt can be given colors and attributes to make things easier to find and use.

Note

Objects must be given both a foreground and background color (it is not possible to specify one or the other).

Colors can be specified in two ways, using their name such as green, blue, or by their number in the palette, such as color12, color207(the palette consists of the 256 Xterm colors).

Named colours may also be prefixed by a modifier . bright or light will make the color boldfaced or light (e.g., brightred). alert to make a blinking/alert color (e.g., alertred).

The precise behavior depends on the terminal and its configuration. In particular, the boldfaced/light difference and such background colors may be available only for terminals configured with at least 16 colors, as specified by the $TERM environment variable.

foreground and background can be one of the following:

  • white

  • black

  • green

  • magenta

  • blue

  • cyan

  • yellow

  • red

  • default

In addition to the colors, objects may have their attributes set:

  • none

  • bold

  • reverse

  • standout

  • underline

If your terminal supports it, the special keyword default can be used as a transparent color. The value brightdefault is also valid. If NeoMutt is linked against the S-Lang library, you also need to set the $COLORFGBG environment variable to the default colors of your terminal for this to work; for example (for Bourne-like shells):

set COLORFGBG="green;black"
export COLORFGBG

Note

The S-Lang library requires you to use the lightgray and brown keywords instead of white and yellow when setting this variable.

10.2. Simple Colors

Most of NeoMutt's colorable objects follow simple rules. They don't use a pattern and any new configuration will overwrite the old colours.

Simple colors can be undone by setting the foreground and background to default, or by using the uncolor command.

These are general NeoMutt objects:

Table 3.6. Simple Colours

Colour Name Description
attachment Colour for attachment headers
bold Highlighting bold patterns in the body of messages
error Error messages printed by NeoMutt
hdrdefault Default colour of the message header in the pager
indicator Arrow or bar used to indicate the current item in a menu
markers The "+" markers at the beginning of wrapped lines in the pager
message Informational messages
normal Default colour for all text
options The key letters in multi-choice questions
progress Visual progress bar
prompt A question
search Highlighting of words in the pager
signature Email's signature lines (.sig)
tilde The "~" used to pad blank lines in the pager
tree Thread tree drawn in the message index and attachment menu
underline Highlighting underlined patterns in the body of messages
warning Warning messages

# Make error messages white text on a red background
color error white red
# Make questions bold, underlined, with light blue text (with default background)
color prompt bold underline cyan default
uncolor error
uncolor prompt

Each of these objects will colour a certain expando in the index. See $index_format for more details.

Table 3.7. Simple Index Colours

Colour Name Description
index_collapsed Number of messages in a collapsed thread, %M
index_date Date field, %d %D %{fmt} %[fmt] %(fmt)
index_label Message label, %y %Y
index_number Message number, %C
index_size Message size, %c %cr %l
index_tags Transformed message tags, %g %J

color index_date green default
uncolor index_date

These are sidebar objects. See Sidebar Intro for more details.

Table 3.8. Simple Sidebar Colours

Colour Name Description
sidebar_divider The dividing line between the Sidebar and the Index/Pager panels
sidebar_flagged Mailboxes containing flagged mail
sidebar_highlight Cursor to select a mailbox
sidebar_indicator The mailbox open in the Index panel
sidebar_new Mailboxes containing new mail
sidebar_ordinary Mailboxes that have no new/flagged mails, etc
sidebar_spoolfile Mailbox that receives incoming mail
sidebar_unread Mailboxes containing unread mail

color sidebar_divider brightblack default
uncolor sidebar_divider

These are compose objects.

Note

The compose objects use a slightly different format of command. They prefix the style with the word compose.

Table 3.9. Simple Compose Colours

Colour Name Description
header Header labels, e.g. From:
security_encrypt Mail will be encrypted
security_sign Mail will be signed
security_both Mail will be encrypted and signed
security_none Mail will not be encrypted or signed

color compose header bold white default
uncolor compose header

The quoted objects refer to quoted lines in an email reply. They are defined using the $reply_regex config variable.

The quoted email colours don't use pattern. The first colour, quoted provides a default colour for all quoted text. Also, each diffent level of quoting can be given a different colour using, quoted1, quoted2, quoted3 up to quoted9.

Table 3.10. Quoted Email Colours

Colour Name Description
quoted Text matching $quote_regex in the body of a message
quoted1 1 level deeper quoted text, e.g. > > text
quoted2 2 level deeper quoted text, e.g. > > > text
... ...
quoted9 9 level deeper quoted text

color quoted brightblue default
color quoted1 brightgreen default
color quoted2 yellow default
uncolor quoted
uncolor quoted1
uncolor quoted2

10.3. Color Lists

Some objects in NeoMutt support lists of color rules. Each rule has a pattern and a color. Each is checked in turn and any matching rules are applied cumulatively (overlaid).

When applying the colours, each pattern will be tested against the field to be colored. All of the matching patterns will have their colors applied in the order they are configured.

The color lists work in slightly different ways to each other.

attach_headers, body and header match a regular expression (regex) in the header/body of a email.

index objects match a pattern in the email index (see Section 3, “Patterns: Searching, Limiting and Tagging”) Note that IMAP server-side searches (=b, =B, =h) are not supported for color index patterns.

When $header_color_partial is unset (the default), a header matched by regex will have color applied to the entire header. When set, color is applied only to the exact text matched by regex .

For the status list, the regular expression is optional. Without one, the command will set the default style for the status bar. With a regex (and an optional number), it's possible to style parts of the status bar. See: Status-Color feature for more detail.

Color lists can be undone by using the uncolor command and the pattern or *to match.

Table 3.11. Colour Regex Lists

Colour Name Match Description
attach_headers regex Attachment headers
body regex Email body
header regex Email headers
index pattern Default highlighting of the entire index line
index_author pattern Author in the index, %A %a %F %L %n
index_flags pattern Flags in the index, %S %Z
index_subject pattern Subject in the index, %s
index_tag pattern Tags in the index, %G
status regex Status bar

# Highlight emails from work (entire line)
color index          cyan default "~f @work.com"
# Extra highlighting for the boss (just the author column)
color index_author   cyan red     "~f boss@work.com"
uncolor index          "~f @work.com"
# Clear all index_author colors
uncolor index_author   *
# Add some highlights to the body of an email
color body    bold red    default "(urgent|important)"
color body         yellow default "(warning|notice)"
# Make the label header red
color header       cyan   default "X-Label"
uncolor body    "(urgent|important)"
# Clear all body colors
uncolor body    *
uncolor header  "X-Label"
# Set the default color for the entire status line
color status blue white
# Highlight New, Deleted, or Flagged emails
color status brightred white '(New|Del|Flag):[0-9]+'
# Highlight the contents of the []s but not the [] themselves
color status red default '\[([^]]+)\]' 1
uncolor status '(New|Del|Flag):[0-9]+'
uncolor status *

10.4. Mono Color

If your terminal does not support color, it is still possible change the video attributes through the use of the mono command. Usage:

mono object attribute
mono{ header| body} attribute regex
mono index-object attribute pattern
unmono{ index-object| header| body} { * | pattern ... }

For object , composeobject , and attribute , see the color command.

11. Message Header Display

11.1. Header Display

When displaying a message in the pager, NeoMutt folds long header lines at $wrap columns. Though there're precise rules about where to break and how, NeoMutt always folds headers using a tab for readability. (Note that the sending side is not affected by this, NeoMutt tries to implement standards compliant folding.)

11.2. Selecting Headers

Usage:

ignore pattern [ pattern ...]
unignore{ * | pattern ... }

Messages often have many header fields added by automatic processing systems, or which may not seem useful to display on the screen. This command allows you to specify header fields which you don't normally want to see in the pager.

You do not need to specify the full header field name. For example, ignore content- will ignore all header fields that begin with the pattern content-. ignore * will ignore all headers.

To remove a previously added token from the list, use the unignore command. The unignore command will make NeoMutt display headers with the given pattern. For example, if you do ignore x- it is possible to unignore x-mailer.

unignore * will remove all tokens from the ignore list.

Example 3.10. Header weeding

# Sven's draconian header weeding
ignore *
unignore from date subject to cc
unignore organization organisation x-mailer: x-newsreader: x-mailing-list:
unignore posted-to:

11.3. Ordering Displayed Headers

Usage:

hdr_order header [ header ...]
unhdr_order{ * | header ... }

With the hdr_order command you can specify an order in which NeoMutt will attempt to present these headers to you when viewing messages.

unhdr_order * will clear all previous headers from the order list, thus removing the header order effects set by the system-wide startup file.

Example 3.11. Configuring header display order

hdr_order From Date: From: To: Cc: Subject:

12. Alternative Addresses

Usage:

alternates[ -group name ...] regex [ regex ...]
unalternates[ -group name ...] { * | regex ... }

With various functions, NeoMutt will treat messages differently, depending on whether you sent them or whether you received them from someone else. For instance, when replying to a message that you sent to a different party, NeoMutt will automatically suggest to send the response to the original message's recipients – responding to yourself won't make much sense in many cases. (See $reply_to.)

Many users receive e-mail under a number of different addresses. To fully use NeoMutt's features here, the program must be able to recognize what e-mail addresses you receive mail under. That's the purpose of the alternates command: It takes a list of regular expressions, each of which can identify an address under which you receive e-mail.

As addresses are matched using regular expressions and not exact strict comparisons, you should make sure you specify your addresses as precise as possible to avoid mismatches. For example, if you specify:

alternates user@example

NeoMutt will consider some-user@example as being your address, too which may not be desired. As a solution, in such cases addresses should be specified as:

alternates '^user@example$'

The -group flag causes all of the subsequent regular expressions to be added to the named group.

The unalternates command can be used to write exceptions to alternates patterns. If an address matches something in an alternates command, but you nonetheless do not think it is from you, you can list a more precise pattern under an unalternates command.

To remove a regular expression from the alternates list, use the unalternates command with exactly the same regex . Likewise, if the regex for an alternates command matches an entry on the unalternates list, that unalternates entry will be removed. If the regex for unalternates is *, all entries on alternates will be removed.

13. Mailing Lists

Usage:

lists[ -group name ...] regex [ regex ...]
unlists{ * | regex ... }
subscribe[ -group name ...] regex [ regex ...]
unsubscribe{ * | regex ... }

NeoMutt has a few nice features for handling mailing lists. In order to take advantage of them, you must specify which addresses belong to mailing lists, and which mailing lists you are subscribed to. NeoMutt also has limited support for auto-detecting mailing lists: it supports parsing mailto:links in the common List-Post:header which has the same effect as specifying the list address via the lists command (except the group feature). Once you have done this, the <list-reply> function will work for all known lists. Additionally, when you send a message to a known list and $followup_to is set, NeoMutt will add a Mail-Followup-To header. For unsubscribed lists, this will include your personal address, ensuring you receive a copy of replies. For subscribed mailing lists, the header will not, telling other users' mail user agents not to send copies of replies to your personal address.

Note

The Mail-Followup-To header is a non-standard extension which is not supported by all mail user agents. Adding it is not bullet-proof against receiving personal CCs of list messages. Also note that the generation of the Mail-Followup-To header is controlled by the $followup_to configuration variable since it's common practice on some mailing lists to send Cc upon replies (which is more a group- than a list-reply).

More precisely, NeoMutt maintains lists of patterns for the addresses of known and subscribed mailing lists. Every subscribed mailing list is known. To mark a mailing list as known, use the list command. To mark it as subscribed, use subscribe .

You can use regular expressions with both commands. To mark all messages sent to a specific bug report's address on Debian's bug tracking system as list mail, for instance, you could say

subscribe [0-9]+.*@bugs.debian.org

as it's often sufficient to just give a portion of the list's e-mail address.

Specify as much of the address as you need to to remove ambiguity. For example, if you've subscribed to the NeoMutt mailing list, you will receive mail addressed to neomutt-users@neomutt.org. So, to tell NeoMutt that this is a mailing list, you could add lists neomutt-users@to your initialization file. To tell NeoMutt that you are subscribed to it, add subscribe neomutt-users to your initialization file instead. If you also happen to get mail from someone whose address is neomutt-users@example.com, you could use lists ^neomutt-users@neomutt\\.org$or subscribe ^neomutt-users@neomutt\\.org$to match only mail from the actual list.

The -group flag adds all of the subsequent regular expressions to the named address group in addition to adding to the specified address list.

The unlists command is used to remove a token from the list of known and subscribed mailing-lists. Use unlists * to remove all tokens.

To remove a mailing list from the list of subscribed mailing lists, but keep it on the list of known mailing lists, use unsubscribe .

14. Using Multiple Spool Mailboxes

Usage:

mbox-hook regex mailbox

This command is used to move read messages from a specified mailbox to a different mailbox automatically when you quit or change folders. regex is a regular expression specifying the mailbox to treat as a spool mailbox and mailbox specifies where mail should be saved when read.

The regex parameter has mailbox shortcut expansion performed on the first character. See Mailbox Matching in Hooks for more details.

Note that execution of mbox-hooks is dependent on the $move configuration variable. If set to no(the default), mbox-hooks will not be executed.

Unlike some of the other hook commands, only the first matching regex is used (it is not possible to save read mail in more than a single mailbox).

15. Monitoring Incoming Mail

Usage:

mailboxes mailbox [ mailbox ...]
named-mailboxes description mailbox { description mailbox ...}
unmailboxes{ * | mailbox ... }

This command specifies folders which can receive mail and which will be checked for new messages periodically.

folder can either be a local file or directory (Mbox/Mmdf or Maildir/Mh). If NeoMutt was built with POP and/or IMAP support, folder can also be a POP/IMAP folder URL. The URL syntax is described in Section 1.2, “URL Syntax”, POP and IMAP are described in Section 3, “POP3 Support” and Section 4, “IMAP Support” respectively.

NeoMutt provides a number of advanced features for handling (possibly many) folders and new mail within them, please refer to Chapter 24, New Mail Featurefor details (including in what situations and how often NeoMutt checks for new mail). Additionally, $new_mail_command can be used to run a command when new mail is detected.

The unmailboxes command is used to remove a token from the list of folders which receive mail. unmailboxes can be used on the mailbox path, $folder-abbreviated path, or description. Use unmailboxes * to remove all tokens.

Note

The folders in the mailboxes command are resolved when the command is executed, so if these names contain shortcut characters(such as = and !), any variable definition that affects these characters (like $folder and $spoolfile) should be set before the mailboxes command. If none of these shortcuts are used, a local path should be absolute as otherwise NeoMutt tries to find it relative to the directory from where NeoMutt was started which may not always be desired.

16. User-Defined Headers

Usage:

my_hdr string
unmy_hdr{ * | field ... }

The my_hdr command allows you to create your own header fields which will be added to every message you send and appear in the editor if $edit_headers is set.

For example, if you would like to add an Organization: header field to all of your outgoing messages, you can put the command something like shown in Example 3.12, “Defining custom headers” in your .neomuttrc.

Example 3.12. Defining custom headers

my_hdr Organization: A Really Big Company, Anytown, USA

Note

Space characters are not allowed between the keyword and the colon ( :). The standard for electronic mail (RFC2822) says that space is illegal there, so NeoMutt enforces the rule.

If you would like to add a header field to a single message, you should either set the $edit_headers variable, or use the <edit-headers>function (default: E) in the compose menu so that you can edit the header of your message along with the body.

To remove user defined header fields, use the unmy_hdr command. You may specify an asterisk ( *) to remove all header fields, or the fields to remove. For example, to remove all To and Cc header fields, you could use:

unmy_hdr to cc

17. Specify Default Fcc: and/or Save Mailbox

Usage:

fcc-save-hook pattern mailbox
fcc-hook pattern mailbox
save-hook pattern mailbox

fcc-save-hook is a shortcut, equivalent to doing both a fcc-hook and a save-hook with its arguments, including %-expansion on mailbox according to $index_format.

fcc-hook is used to save outgoing mail in a mailbox other than $record. NeoMutt searches the initial list of message recipients for the first matching pattern and uses mailbox as the default Fcc: mailbox. If no match is found the message will be saved to $record mailbox.

fcc-hook [@.]aol\\.com$ +spammers

...will save a copy of all messages going to the aol.com domain to the +spammers mailbox by default.

save-hook is used to override the default mailbox used when saving messages. mailbox will be used as the default if the message matches pattern .

Example 3.13. Using %-expandos in save-hook

# default: save all to ~/Mail/<author name>
save-hook . ~/Mail/%F
# save from me@turing.cs.hmc.edu and me@cs.hmc.edu to $folder/elkins
save-hook me@(turing\\.)?cs\\.hmc\\.edu$ +elkins
# save from aol.com to $folder/spam
save-hook aol\\.com$ +spam

Also see the fcc-save-hook command.

To provide more flexibility and good defaults, NeoMutt applies the expandos of $index_format to mailbox after it was expanded. See Message Matching in Hooks for information on the exact format of pattern .

18. Change Settings Based Upon Message Recipients

Usage:

reply-hook pattern command
send-hook pattern command
send2-hook pattern command

These commands can be used to execute arbitrary configuration commands based upon recipients of the message. pattern is used to match the message, see Message Matching in Hooks for details. command is executed when pattern matches.

reply-hook is matched against the message you are replying to , instead of the message you are sending . send-hook is matched against all messages, both new and replies .

Note

reply-hook s are matched before the send-hook , regardless of the order specified in the user's configuration file. However, you can inhibit send-hook in the reply case by using the pattern '! ~Q'( not replied , see Message Matching in Hooks) in the send-hook to tell when reply-hook have been executed.

send2-hook is matched every time a message is changed, either by editing it, or by using the compose menu to change its recipients or subject. send2-hook is executed after send-hook , and can, e.g., be used to set parameters such as the $sendmail variable depending on the message's sender address.

For each type of send-hook or reply-hook , when multiple matches occur, commands are executed in the order they are specified in the .neomuttrc(for that type of hook).

Example: send-hook work " set mime_forward signature=''"

Another typical use for this command is to change the values of the $attribution, $attribution_locale, and $signature variables in order to change the language of the attributions and signatures based upon the recipients.

Note

send-hook 's are only executed once after getting the initial list of recipients. They are not executed when resuming a postponed draft. Adding a recipient after replying or editing the message will not cause any send-hook to be executed, similarly if $autoedit is set (as then the initial list of recipients is empty). Also note that my_hdr commands which modify recipient headers, or the message's subject, don't have any effect on the current message when executed from a send-hook .

19. Change Settings Before Formatting a Message

Usage:

message-hook pattern command

This command can be used to execute arbitrary configuration commands before viewing or formatting a message based upon information about the message. command is executed if the pattern matches the message to be displayed. When multiple matches occur, commands are executed in the order they are specified in the .neomuttrc.

See Message Matching in Hooks for information on the exact format of pattern .

Example:

message-hook ~A 'set pager=builtin'
message-hook '~f freshmeat-news' 'set pager="less \"+/^  subject: .*\""'

20. Choosing the Cryptographic Key of the Recipient

Usage:

crypt-hook regex keyid

When encrypting messages with PGP/GnuPG or OpenSSL, you may want to associate a certain key with a given e-mail address automatically, either because the recipient's public key can't be deduced from the destination address, or because, for some reasons, you need to override the key NeoMutt would normally use. The crypt-hook command provides a method by which you can specify the ID of the public key to be used when encrypting messages to a certain recipient. You may use multiple crypt-hooks with the same regex; multiple matching crypt-hooks result in the use of multiple keyids for a recipient. During key selection, NeoMutt will confirm whether each crypt-hook is to be used (unless the $crypt_confirmhook option is unset). If all crypt-hooks for a recipient are declined, NeoMutt will use the original recipient address for key selection instead.

The meaning of keyid is to be taken broadly in this context: You can either put a numerical key ID or fingerprint here, an e-mail address, or even just a real name.

21. Dynamically Changing $index_format using Patterns

Usage:

index-format-hook name [!]pattern format-string

This command is used to inject format strings dynamically into $index_format based on pattern matching against the current message.

The $index_format expando %@name@ specifies a placeholder for the injection. Index-format-hooks with the same name are matched using pattern against the current message. Matching is done in the order specified in the .muttrc, with the first match being used. The hook's format-string is then substituted and evaluated.

Because the first match is used, best practice is to put a catch-all ~A pattern as the last hook. Here is an example showing how to implement dynamic date formatting:

set index_format="%4C %-6@date@ %-15.15F %Z (%4c) %s"

index-format-hook  date  "~d<1d"    "%[%H:%M]"
index-format-hook  date  "~d<1m"    "%[%a %d]"
index-format-hook  date  "~d<1y"    "%[%b %d]"
index-format-hook  date  "~A"       "%[%m/%y]"

Another example, showing a way to prepend to the subject. Note that without a catch-all ~A pattern, no match results in the expando being replaced with an empty string.

set index_format="%4C %@subj_flags@%s"

index-format-hook  subj_flags  "~f boss@example.com"    "** BOSS ** "
index-format-hook  subj_flags  "~f spouse@example.com"  ":-) "

22. Adding Key Sequences to the Keyboard Buffer

Usage:

push string

This command adds the named string to the beginning of the keyboard buffer. The string may contain control characters, key names and function names like the sequence string in the macro command. You may use it to automatically run a sequence of commands at startup, or when entering certain folders. For example, Example 3.14, “Embedding push in folder-hook shows how to automatically collapse all threads when entering a folder.

Example 3.14. Embedding push in folder-hook

folder-hook . 'push <collapse-all>'

For using functions like shown in the example, it's important to use angle brackets ( < and >) to make NeoMutt recognize the input as a function name. Otherwise it will simulate individual just keystrokes, i.e. push collapse-all would be interpreted as if you had typed c, followed by o, followed by l, ..., which is not desired and may lead to very unexpected behavior.

Keystrokes can be used, too, but are less portable because of potentially changed key bindings. With default bindings, this is equivalent to the above example:

folder-hook . 'push \eV'

because it simulates that Esc+V was pressed (which is the default binding of <collapse-all>).

23. Executing Functions

Usage:

exec function [ function ...]

This command can be used to execute any function. Functions are listed in the function reference. exec function is equivalent to push <function> .

24. Message Scoring

Usage:

score pattern value
unscore{ * | pattern ... }

The score commands adds value to a message's score if pattern matches it. pattern is a string in the format described in the patterns section (note: For efficiency reasons, patterns which scan information not available in the index, such as ~b, ~B, ~h, ~M, or ~X may not be used). value is a positive or negative integer. A message's final score is the sum total of all matching score entries. However, you may optionally prefix value with an equal sign ( =) to cause evaluation to stop at a particular entry if there is a match. Negative final scores are rounded up to 0.

The unscore command removes score entries from the list. You must specify the same pattern specified in the score command for it to be removed. The pattern * is a special token which means to clear the list of all score entries.

Scoring occurs as the messages are read in, before the mailbox is sorted. Because of this, patterns which depend on threading, such as ~= , ~$ , and ~() , will not work by default. A workaround is to push the scoring command in a folder hook. This will cause the mailbox to be rescored after it is opened and input starts being processed:

folder-hook . 'push "<enter-command>score ~= 10<enter>"'

25. Spam Detection

Usage:

spam pattern format
nospam{ * | pattern }

NeoMutt has generalized support for external spam-scoring filters. By defining your spam patterns with the spam and nospam commands, you can limit , search , and sort your mail based on its spam attributes, as determined by the external filter. You also can display the spam attributes in your index display using the %H selector in the $index_format variable. (Tip: try %?H?[%H] ?to display spam tags only when they are defined for a given message.)

Note: the value displayed by %H and searched by ~H is stored in the header cache. NeoMutt isn't smart enough to invalidate a header cache entry based on changing spam rules, so if you aren't seeing correct %H values, try temporarily turning off the header cache. If that fixes the problem, then once your spam rules are set to your liking, remove your stale header cache files and turn the header cache back on.

Your first step is to define your external filter's spam patterns using the spam command. pattern should be a regular expression that matches a header in a mail message. If any message in the mailbox matches this regular expression, it will receive a spam tag or spam attribute(unless it also matches a nospam pattern – see below.) The appearance of this attribute is entirely up to you, and is governed by the format parameter. format can be any static text, but it also can include back-references from the pattern expression. (A regular expression back-reference refers to a sub-expression contained within parentheses.) %1 is replaced with the first back-reference in the regex, %2 with the second, etc.

To match spam tags, NeoMutt needs the corresponding header information which is always the case for local and POP folders but not for IMAP in the default configuration. Depending on the spam header to be analyzed, $imap_headers may need to be adjusted.

If you're using multiple spam filters, a message can have more than one spam-related header. You can define spam patterns for each filter you use. If a message matches two or more of these patterns, and the $spam_separator variable is set to a string, then the message's spam tag will consist of all the format strings joined together, with the value of $spam_separator separating them.

For example, suppose one uses DCC, SpamAssassin, and PureMessage, then the configuration might look like in Example 3.15, “Configuring spam detection”.

Example 3.15. Configuring spam detection

spam "X-DCC-.*-Metrics:.*(....)=many"         "90+/DCC-%1"
spam "X-Spam-Status: Yes"                     "90+/SA"
spam "X-PerlMX-Spam: .*Probability=([0-9]+)%" "%1/PM"
set spam_separator=", "

If then a message is received that DCC registered with many hits under the Fuz2 checksum, and that PureMessage registered with a 97% probability of being spam, that message's spam tag would read 90+/DCC-Fuz2, 97/PM. (The four characters before =many in a DCC report indicate the checksum used – in this case, Fuz2.)

If the $spam_separator variable is unset, then each spam pattern match supersedes the previous one. Instead of getting joined format strings, you'll get only the last one to match.

The spam tag is what will be displayed in the index when you use %H in the $index_format variable. It's also the string that the ~H pattern-matching expression matches against for <search>and <limit>functions. And it's what sorting by spam attribute will use as a sort key.

That's a pretty complicated example, and most people's actual environments will have only one spam filter. The simpler your configuration, the more effective NeoMutt can be, especially when it comes to sorting.

Generally, when you sort by spam tag, NeoMutt will sort lexically – that is, by ordering strings alphanumerically. However, if a spam tag begins with a number, NeoMutt will sort numerically first, and lexically only when two numbers are equal in value. (This is like UNIX's sort -n.) A message with no spam attributes at all – that is, one that didn't match any of your spam patterns – is sorted at lowest priority. Numbers are sorted next, beginning with 0 and ranging upward. Finally, non-numeric strings are sorted, with a taking lower priority than z. Clearly, in general, sorting by spam tags is most effective when you can coerce your filter to give you a raw number. But in case you can't, NeoMutt can still do something useful.

The nospam command can be used to write exceptions to spam patterns. If a header pattern matches something in a spam command, but you nonetheless do not want it to receive a spam tag, you can list a more precise pattern under a nospam command.

If the pattern given to nospam is exactly the same as the pattern on an existing spam list entry, the effect will be to remove the entry from the spam list, instead of adding an exception. Likewise, if the pattern for a spam command matches an entry on the nospam list, that nospam entry will be removed. If the pattern for nospam is *, all entries on both lists will be removed. This might be the default action if you use spam and nospam in conjunction with a folder-hook .

You can have as many spam or nospam commands as you like. You can even do your own primitive spam detection within NeoMutt – for example, if you consider all mail from MAILER-DAEMON to be spam, you can use a spam command like this:

spam "^From: .*MAILER-DAEMON"       "999"

26. Setting and Querying Variables

26.1. Variable Types

NeoMutt supports these types of configuration variables:

boolean

A boolean expression, either yes or no.

number

A signed integer number in the range -32768 to 32767.

number (long)

A signed integer number in the range -2147483648 to 2147483647.

string

Arbitrary text.

path

A specialized string for representing paths including support for mailbox shortcuts (see Section 10, “Mailbox Shortcuts”) as well as tilde ( ~) for a user's home directory and more.

quadoption

Like a boolean but triggers a prompt when set to ask-yes or ask-no with yes and no preselected respectively.

sort order

A specialized string allowing only particular words as values depending on the variable.

regular expression

A regular expression, see Section 2, “Regular Expressions” for an introduction.

folder type

Specifies the type of folder to use: mbox , mmdf , mh or maildir . Currently only used to determine the type for newly created folders.

e-mail address

An email address either with or without realname. The older user@example.org (Joe User) form is supported but strongly deprecated.

user-defined

Arbitrary text, see Section 26.3, “User-Defined Variables” for details.

26.2. Commands

The following commands are available to manipulate and query variables:

Usage:

set{ [ no| inv| &| ?] variable } [...]
set{ variable=value | variable+=increment | variable-=decrement } [...]
unset variable [ variable ...]
reset variable [ variable ...]
toggle variable [ variable ...]

This command is used to set (and unset) configuration variables. There are four basic types of variables: boolean, number, string and quadoption. boolean variables can be set (true) or unset (false). number variables can be assigned a positive integer value. Value of number variables can be incremented += and decremented -= . string variables consist of any number of printable characters and must be enclosed in quotes if they contain spaces or tabs. You may also use the escape sequences \n and \t for newline and tab, respectively. quadoption variables are used to control whether or not to be prompted for certain actions, or to specify a default action. A value of yes will cause the action to be carried out automatically as if you had answered yes to the question. Similarly, a value of no will cause the action to be carried out as if you had answered no. A value of ask-yes will cause a prompt with a default answer of yes and ask-no will provide a default answer of no.

Prefixing a variable with no will unset it. Example: set noaskbcc.

For boolean variables, you may optionally prefix the variable name with inv to toggle the value (on or off). This is useful when writing macros. Example: set invsmart_wrap.

The toggle command automatically prepends the inv prefix to all specified variables.

The unset command automatically prepends the no prefix to all specified variables.

Using the <enter-command>function in the index menu, you can query the value of a variable by prefixing the name of the variable with a question mark:

set ?allow_8bit

The question mark is actually only required for boolean and quadoption variables.

The reset command resets all given variables to the compile time defaults (hopefully mentioned in this manual). If you use the command set and prefix the variable with & this has the same behavior as the reset command.

With the reset command there exists the special variable all, which allows you to reset all variables to their system defaults.

26.3. User-Defined Variables

26.3.1. Introduction

Along with the variables listed in the Configuration variables section, NeoMutt supports user-defined variables with names starting with my_ as in, for example, my_cfgdir.

The set command either creates a custom my_ variable or changes its value if it does exist already. The unset and reset commands remove the variable entirely.

Since user-defined variables are expanded in the same way that environment variables are (except for the shell-escape command and backtick expansion), this feature can be used to make configuration files more readable.

26.3.2. Examples

The following example defines and uses the variable my_cfgdir to abbreviate the calls of the source command:

Example 3.16. Using user-defined variables for config file readability

set my_cfgdir = $HOME/neomutt/config
source $my_cfgdir/hooks $my_cfgdir/macros
# more source commands...

A custom variable can also be used in macros to backup the current value of another variable. In the following example, the value of the $delete is changed temporarily while its original value is saved as my_delete. After the macro has executed all commands, the original value of $delete is restored.

Example 3.17. Using user-defined variables for backing up other config option values

macro pager ,x '\
<enter-command>set my_delete=$delete<enter>\
<enter-command>set delete=yes<enter>\
...\
<enter-command>set delete=$my_delete<enter>'

Since NeoMutt expands such values already when parsing the configuration file(s), the value of $my_delete in the last example would be the value of $delete exactly as it was at that point during parsing the configuration file. If another statement would change the value for $delete later in the same or another file, it would have no effect on $my_delete. However, the expansion can be deferred to runtime, as shown in the next example, when escaping the dollar sign.

Example 3.18. Deferring user-defined variable expansion to runtime

macro pager <PageDown> "\
<enter-command> set my_old_pager_stop=\$pager_stop pager_stop<Enter>\
<next-page>\
<enter-command> set pager_stop=\$my_old_pager_stop<Enter>\
<enter-command> unset my_old_pager_stop<Enter>"

Note that there is a space between <enter-command>and the set configuration command, preventing NeoMutt from recording the macro 's commands into its history.

26.4. Type Conversions

Variables are always assigned string values which NeoMutt parses into its internal representation according to the type of the variable, for example an integer number for numeric types. For all queries (including $-expansion) the value is converted from its internal type back into string. As a result, any variable can be assigned any value given that its content is valid for the target. This also counts for custom variables which are of type string. In case of parsing errors, NeoMutt will print error messages. Example 3.19, “Type conversions using variables” demonstrates type conversions.

Example 3.19. Type conversions using variables

set my_lines = "5"
# value is string "5"
set pager_index_lines = $my_lines
# value is integer 5
set my_sort = "date-received"
# value is string "date-received"
set sort = "last-$my_sort"
# value is sort last-date-received
set my_inc = $read_inc
# value is string "10" (default of $read_inc)
set my_foo = $my_inc
# value is string "10"

These assignments are all valid. If, however, the value of $my_lines would have been five(or something else that cannot be parsed into a number), the assignment to $pager_index_lines would have produced an error message.

Type conversion applies to all configuration commands which take arguments. But please note that every expanded value of a variable is considered just a single token. A working example is:

set my_pattern = "~A"
set my_number = "10"
# same as: score ~A +10
score $my_pattern +$my_number

What does not work is:

set my_mx = "+mailbox1 +mailbox2"
mailboxes $my_mx +mailbox3

because the value of $my_mx is interpreted as a single mailbox named +mailbox1 +mailbox2 and not two distinct mailboxes.

27. Reading Initialization Commands From Another File

Usage:

source filename

This command allows the inclusion of initialization commands from other files. For example, I place all of my aliases in ~/.mail_aliases so that I can make my ~/.neomuttrc readable and keep my aliases private.

If the filename begins with a tilde ( ~), it will be expanded to the path of your home directory.

If the filename ends with a vertical bar ( |), then filename is considered to be an executable program from which to read input (e.g. source ~/bin/myscript|).

28. Removing Hooks

Usage:

unhook{ * | hook-type }

This command permits you to flush hooks you have previously defined. You can either remove all hooks by giving the * character as an argument, or you can remove all hooks of a specific type by saying something like unhook send-hook.

29. Format Strings

29.1. Basic usage

Format strings are a general concept you'll find in several locations through the NeoMutt configuration, especially in the $index_format, $pager_format, $status_format, and other related variables. These can be very straightforward, and it's quite possible you already know how to use them.

The most basic format string element is a percent symbol followed by another character. For example, %s represents a message's Subject: header in the $index_format variable. The expandos available are documented with each format variable, but there are general modifiers available with all formatting expandos, too. Those are our concern here.

Some of the modifiers are borrowed right out of C (though you might know them from Perl, Python, shell, or another language). These are the [-]m.n modifiers, as in %-12.12s. As with such programming languages, these modifiers allow you to specify the minimum and maximum size of the resulting string, as well as its justification. If the - sign follows the percent, the string will be left-justified instead of right-justified. If there's a number immediately following that, it's the minimum amount of space the formatted string will occupy – if it's naturally smaller than that, it will be padded out with spaces. If a decimal point and another number follow, that's the maximum space allowable – the string will not be permitted to exceed that width, no matter its natural size. Each of these three elements is optional, so that all these are legal format strings: %-12s, %4c, %.15F and %-12.15L.

NeoMutt adds some other modifiers to format strings. If you use an equals symbol ( =) as a numeric prefix (like the minus above), it will force the string to be centered within its minimum space range. For example, %=14y will reserve 14 characters for the %y expansion – that's the set of message keywords (formerly X-Label). If the expansion results in a string less than 14 characters, it will be centered in a 14-character space. If the X-Label for a message were test, that expansion would look like      test     .

There are two very little-known modifiers that affect the way that an expando is replaced. If there is an underline ( _) character between any format modifiers (as above) and the expando letter, it will expands in all lower case. And if you use a colon ( :), it will replace all decimal points with underlines.

29.2. Conditionals

Depending on the format string variable, some of its sequences can be used to optionally print a string if their value is nonzero. For example, you may only want to see the number of flagged messages if such messages exist, since zero is not particularly meaningful. To optionally print a string based upon one of the above sequences, the following construct is used:

%?<sequence_char>?<optional_string>?

where sequence_char is an expando, and optional_string is the string you would like printed if sequence_char is nonzero. optional_string may contain other sequences as well as normal text, but you may not nest optional strings.

Here is an example illustrating how to optionally print the number of new messages in a mailbox in $status_format:

%?n?%n new messages.?

You can also switch between two strings using the following construct:

%?<sequence_char>?<if_string>&<else_string>?

If the value of sequence_char is non-zero, if_string will be expanded, otherwise else_string will be expanded.

The conditional sequences can also be nested by using the %< and > operators. The %? notation can still be used but requires quoting. For example:

%<x?true&false>
%<x?%<y?%<z?xyz&xy>&x>&none>

For more examples, see Chapter 23, Nested If Feature

29.3. Filters

Any format string ending in a vertical bar ( |) will be expanded and piped through the first word in the string, using spaces as separator. The string returned will be used for display. If the returned string ends in %, it will be passed through the formatter a second time. This allows the filter to generate a replacement format string including % expandos.

All % expandos in a format string are expanded before the script is called so that:

Example 3.20. Using external filters in format strings

set status_format="script.sh '%r %f (%L)'|"

will make NeoMutt expand %r, %f and %L before calling the script. The example also shows that arguments can be quoted: the script will receive the expanded string between the single quotes as the only argument.

A practical example is the mutt_xtitle script installed in the samples subdirectory of the NeoMutt documentation: it can be used as filter for $status_format to set the current terminal's title, if supported.

29.4. Padding

In most format strings, NeoMutt supports different types of padding using special %-expandos:

%|X

When this occurs, NeoMutt will fill the rest of the line with the character X. For example, filling the rest of the line with dashes is done by setting:

set status_format = "%v on %h: %B: %?n?%n&no? new messages %|-"
%>X

Since the previous expando stops at the end of line, there must be a way to fill the gap between two items via the %>X expando: it puts as many characters X in between two items so that the rest of the line will be right-justified. For example, to not put the version string and hostname the above example on the left but on the right and fill the gap with spaces, one might use (note the space after %>):

set status_format = "%B: %?n?%n&no? new messages %> (%v on %h)"
%*X

Normal right-justification will print everything to the left of the %>, displaying padding and whatever lies to the right only if there's room. By contrast, soft-fill gives priority to the right-hand side, guaranteeing space to display it and showing padding only if there's still room. If necessary, soft-fill will eat text leftwards to make room for rightward text. For example, to right-justify the subject making sure as much as possible of it fits on screen, one might use (note two spaces after %*: the second ensures there's a space between the truncated right-hand side and the subject):

set index_format="%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?)%*  %s"

29.5. Conditional Dates

This feature allows the format of dates in the index to vary based on how recent the message is. This is especially useful in combination with the nested-if feature.

For example, using %<[y?%<[d?%[%H:%M]&%[%m/%d]>&%[%y.%m]>for the date in the $index_format will produce a display like:

   1   + 14.12 Grace Hall      (   13) Gulliver's Travels
   2   + 10/02 Callum Harrison (   48) Huckleberry Finn
   3     12:17 Rhys Lee        (   42) The Lord Of The Rings

29.6. Bytes size display

Various format strings contain expandos that display the size of messages in bytes. This includes %s in $attach_format, %l in $compose_format, %s in $folder_format, %c and %cr in $index_format, and %l and %L in $status_format. There are four configuration variables that can be used to customize how the numbers are displayed.

$size_show_bytes will display the number of bytes when the size is < 1 kilobyte. When unset, kilobytes will be displayed instead.

$size_show_mb will display the number of megabytes when the size is >= 1 megabyte. When unset, kilobytes will be displayed instead (which could be a large number).

$size_show_fractions, will display numbers with a single decimal place for values from 0 to 10 kilobytes, and 1 to 10 megabytes.

$size_units_on_left will display the unit ( K or M) to the left of the number, instead of the right if unset.

These variables also affect size display in a few other places, such as progress indicators and attachment delimiters in the pager.

30. Control allowed header fields in a mailto: URL

Usage:

mailto_allow{ * | header-field ... }
unmailto_allow{ * | header-field ... }

As a security measure, NeoMutt will only add user-approved header fields from a mailto:URL. This is necessary since NeoMutt will handle certain header fields, such as Attach:, in a special way. The mailto_allow and unmailto_allow commands allow the user to modify the list of approved headers.

NeoMutt initializes the default list to contain only the Subject and Body header fields, which are the only requirement specified by the mailto:specification in RFC2368, and the Cc, In-Reply-To, References headers to aid with replies to mailing lists.

Search by Algolia