Skip to content

Instantly share code, notes, and snippets.

@Integralist
Last active April 12, 2024 19:26
Show Gist options
  • Save Integralist/aee36a7e54a4593084157e333ea40a28 to your computer and use it in GitHub Desktop.
Save Integralist/aee36a7e54a4593084157e333ea40a28 to your computer and use it in GitHub Desktop.
Mutt configuration and usage
# http://www.mutt.org/doc/manual/
# decrypt passwords
source "gpg -d ~/.mutt/passwords.gpg |"
# Change the following six lines to match your Gmail account details
set imap_user = "mark.mcdx@gmail.com"
set smtp_url = "smtp://mark.mcdx@gmail.com@smtp.gmail.com:587/"
set smtp_authenticators = "gssapi:login"
set from = "mark.mcdx@gmail.com"
set realname = "Mark McDonnell"
# Change the following line to a different editor you prefer.
set editor = "vim"
# Configuration
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX" # default view would otherwise be 'All Mail'
set imap_check_subscribed
set hostname = gmail.com
set mail_check = 15
set timeout = 30
set imap_keepalive = 300
set postponed = "+[GMail]/Drafts"
set record = "+[GMail]/Sent Mail"
set trash = "imaps://imap.gmail.com/[Gmail]/Trash"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set move = no
set include = yes # include previous email as quote when replying
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
set auto_tag = yes
set pager_stop = yes # prevent opening the next message when reached the end of current message
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc
alternative_order text/plain text/html *
auto_view text/html
bind editor <Tab> complete-query
bind editor ^T complete
bind editor <space> noop # You need the "noop" bind so that the line editor accepts IMAP folders with spaces in their names
macro index,pager d "<save-message>=[Gmail]/Trash<enter><enter><refresh>" "Trash"
macro index gi "<change-folder>=INBOX<enter>" "Go to inbox"
macro index ga "<change-folder>=[Gmail]/All Mail<enter>" "Go to all mail"
macro index gs "<change-folder>=[Gmail]/Starred<enter>" "Go to starred messages"
macro index gd "<change-folder>=[Gmail]/Drafts<enter>" "Go to drafts"
macro index,pager gt "=[Gmail]/Sent Mail" "Go to 'Sent Mail'"
macro index,pager gl ? "Go to 'Label'"
macro index,pager I O "Mark as read"
macro index,pager U O "Mark as unread"
# pip install goobook
# https://gitlab.com/goobook/goobook
set query_command="goobook query %s"
macro index,pager a "<pipe-message>goobook add<return>" "add sender to google contacts"
bind editor <Tab> complete-query
# COLORS
color attachment brightmagenta black
color error brightwhite magenta # errors yell at you in pink/magenta
color hdrdefault yellow black # headers
color indicator black brightyellow # currently selected message
color markers brightcyan black # the + for wrapped pager lines
color message brightcyan black # informational messages, not mail
color normal white black # plain text
color quoted magenta black # quoted text
color search brightgreen black # hilite search patterns in the pager
color signature red black # signature (after "-- ") is red
color status white red # status bar is yellow *on blue*
color tilde blue black # ~'s after message body
color tree red black # thread tree in index menu
color signature brightred black
color underline yellow black
color header cyan black ^(From|Subject): # Important headers
color body green black "(ftp|http)://[^ ]+" # picks up URLs
color body green black [-a-z_0-9.]+@[-a-z_0-9.]+
# Coloring quoted text - coloring the first 7 levels:
color quoted cyan black
color quoted1 yellow black
color quoted2 red black
color quoted3 green black
color quoted4 cyan black
color quoted5 yellow black
color quoted6 red black
color quoted7 green black
# Colorize smileys: :-) ;-) :-/ :-(
color body yellow black "[;:]-[)/(|]"
color body yellow black "[;:][)/(|]"
color body green black "[[:alpha:]]\+://[^ ]*"
color index brightyellow black ~N # New
color index magenta black ~O # Old
color index red black ~F
color index blue black ~T
color index red black ~D

Basic Usage

General commands:

  • /: search
  • /~b <phrase>: search inside all message bodies for phrase
  • /~B <phrase>: search inside all message bodies (and headers) for phrase

Whilst viewing your inbox, and cursor is over a message:

  • $: sync changes
  • d: delete message
  • C-d: delete the whole thread
  • N: mark as 'new' (equivalent to it being 'unread')
  • ENTER: open message
  • /~r DD/MM/YYYY: search for message received on specified date (stops on first match)

Note: YYYY can be omitted but you need DD/MM

Whilst viewing a message:

  • i: exit
  • d: delete message
  • C-d: delete the whole thread
  • C-b: activate urlview
  • arrow keys (left/right): <- next message | -> previous message
  • SPACE: scroll down
  • -: scroll up

Multiple Mutts

You can create an alias for starting Mutt with a different .muttrc file:

alias muttb="mutt -F ~/.muttrc-buzzfeed"

Sending email via Vim

:!mutt -s "your subject" -a % -- foo@bar.org < /dev/null

Vim will convert % into the current buffer's name
Leave off < /dev/null if you wish to edit message body

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment