Hooks#
Commands that trigger actions on specific events, patterns, or conditions.
:account-hook#
Run a command when connecting to an account whose URL matches a regex.
account-hook <regex> <command>β match against the account URL
account-hook imaps://user@work.example.com 'set imap_pass = "s3cret"'
account-hook . 'unset imap_pass'
:folder-hook#
Run a command when entering a mailbox whose path matches a regex.
folder-hook <regex> <command>β match against the folder pathfolder-hook -noregex <string> <command>β match as a literal string
folder-hook . 'set sort = date'
folder-hook INBOX 'set sort = reverse-date'
folder-hook neomutt-devel 'set strict_threads; set sort = threads'
folder-hook -noregex ~/Mail/work 'set from = "jane@work.example.com"'
:send-hook#
Run a command when composing a new message or reply that matches a pattern.
send-hook <pattern> <command>β match against the message being composed
send-hook . 'set signature = ~/.signature'
send-hook '~t boss@company' 'set from = "jane@company.com"'
send-hook '~t @example\\.com' 'set pgp_auto_sign'
:send2-hook#
Run a command whenever a composed message is edited (every time the editor returns).
send2-hook <pattern> <command>β match against the edited message
send2-hook . 'source ~/.config/neomutt/compose-hooks.rc'
:message-hook#
Run a command when viewing a message that matches a pattern.
message-hook <pattern> <command>
message-hook . 'reset pager_stop'
message-hook '~f admin@' 'set pager_stop'
:save-hook#
Set the default save folder when saving messages that match a pattern.
save-hook <pattern> <mailbox>
save-hook '~f boss@company' =work.boss
save-hook '~t neomutt-devel@' =lists.neomutt
save-hook . =saved
:fcc-hook#
Set the sent-mail (Folder Carbon Copy) folder for outgoing messages matching a pattern.
fcc-hook <pattern> <mailbox>
fcc-hook '~t @company\\.com' =sent.work
fcc-hook . =Sent
:fcc-save-hook#
Shorthand β equivalent to setting both fcc-hook and save-hook with the same pattern and mailbox.
fcc-save-hook <pattern> <mailbox>
fcc-save-hook '~f boss@company' =work.boss
fcc-save-hook . =saved
:mbox-hook#
When leaving a mailbox that matches a regex, move read messages to another mailbox.
mbox-hook <regex> <mailbox>
mbox-hook =INBOX =mbox
mbox-hook =Lists/dev =Lists/dev.old
:charset-hook#
Define a charset alias β map a mis-labelled charset to one NeoMutt understands.
charset-hook <alias> <charset>
charset-hook x-unknown windows-1252
charset-hook gb2312 gb18030
:iconv-hook#
Define a system-specific alias for a character set.
iconv-hook <charset> <local-charset>
iconv-hook iso-8859-1 iso-8859-15
:crypt-hook#
Specify which cryptographic key ID to use for recipients matching a regex.
crypt-hook <regex> <keyid>
crypt-hook alice@example.com 0xDEADBEEF
crypt-hook . 0x12345678
:index-format-hook#
Create a named format string that can be used in $index_format and varies based on message patterns.
index-format-hook <name> <pattern> <format-string>β define a ruleindex-format-hook <name> !<pattern> <format-string>β negate the pattern (else clause)
index-format-hook date "~d<1d" "%[%H:%M]"
index-format-hook date "~d<1y" "%[%b %d]"
index-format-hook date "~A" "%[%Y-%m]"
:startup-hook#
Run a command once when NeoMutt starts up, after all config files are read.
startup-hook <command>
startup-hook 'echo "Welcome back!"'
startup-hook 'source ~/.config/neomutt/runtime.rc'
:shutdown-hook#
Run a command just before NeoMutt exits.
shutdown-hook <command>
shutdown-hook 'echo "Goodbye!"'
:timeout-hook#
Run a command when NeoMutt is idle and the $timeout timer expires.
timeout-hook <command>
timeout-hook 'exec check-stats'
:unhook#
Remove all hooks of a given type, or remove all hooks.
unhook *β remove all hooksunhook <hook-type>β remove all hooks of that type
unhook *
unhook send-hook
unhook folder-hook
:hooks#
Display a list of all currently defined hooks.
hooks