Skip to content

Instantly share code, notes, and snippets.

@duclos-cavalcanti
Last active April 4, 2023 00:15
Show Gist options
  • Save duclos-cavalcanti/d1db3ede90d698bc724b2e10daed55a7 to your computer and use it in GitHub Desktop.
Save duclos-cavalcanti/d1db3ede90d698bc724b2e10daed55a7 to your computer and use it in GitHub Desktop.
a base neomutt rc and it's corresponding files within a small idiomatic repo

Basic Neomutt Configuration

NeoMutt is an amazing TUI-based email client that can run from within your terminal. It's lightweight, configurable and easily extendable. This example is shown and configured for a basic Gmail account that requires 2-step authentication and can send encrypted messages with GnuPG.

1. Dependencies

The software listed and how it is installed is exemplified for an arch-based linux system.

  • neomutt
  • gpg
  • pass
  • w3m

(optional)

  • notmuch

Arch Linux

sudo pacman -S neomutt gpg pass w3m

Ubuntu

sudo apt install neomutt pass w3m

2. Gmail

Double-check the support page on app passwords

  1. Go to your google account.
  2. Select Security
  3. Under "Signing in to Google", select App Passwords.
  • On Select App pick mail
  • On Select Device choose custom

3. (Neo)Mutt

  1. Create the directory .config/neomutt at home.
.
├── config
│  ├── alias
│  ├── bind
│  └── colors
├── neomuttrc
└── signature

4. Passwords (GPG and Pass)

pass is a simple password store that keeps passwords inside gpg2. A simple step-by-step on how to use it can be seen below:

  1. create your gpg id: gpg --full-gen-key
  2. pass init <gpg-id>
  3. pass add mutt
  4. pass show mutt

The corresponding lines in your neomuttrc that should use pass to safely give off the password instead of being written as plain text:

set imap_pass = `pass show mutt`
set smtp_pass = `pass show mutt`

5. RC

For questions go here!

Thanks

A lot of the info on this gist has been derived from syncom.

unalias *
alias Lastname.Firstname Full Name <mailbox@domain.tld>
alias -group Groupname Lastname.Firstname Full Name <mailbox@domain.tld>
# vim ft=conf
bind attach,index,pager \CD next-page
bind attach,index,pager \CU previous-page
bind pager g top
bind pager G bottom
bind attach,index g first-entry
bind attach,index G last-entry
# Sidebar binds
bind index,pager \CP sidebar-prev # Ctrl-n to select next folder
bind index,pager \CN sidebar-next # Ctrl-p to select previous folder
bind index,pager \CI sidebar-open # Ctrl-o to open selected folder
bind index,pager \CB sidebar-toggle-visible # Ctrl-b to toggle visibility of the sidebar
# Macros for switching accounts
macro index <f2> '<sync-mailbox><enter-command>source ~/.config/neomutt/username1.rc<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.config/neomutt/username2.rc<enter><change-folder>!<enter>'
# vim ft=conf
# This is an example of the neomutt configuration file
# =========================================================================
# Look
# =========================================================================
#
# =========================================================================
# -------------------------------------------------------------------------
# Name: color
# -------------------------------------------------------------------------
#
# -------------------------------------------------------------------------
# name fg bg
color normal default default
color indicator brightyellow red
color tree default default
# upper bar
color status blue default
color error brightred default
color message red default
color signature red default
color attachment yellow default
color search brightyellow red
color tilde brightmagenta default
color markers red default
color hdrdefault cyan default
color bold green black
color underline yellow black
color index_flags black white ~D
color index_flags green default ~g
color index_flags brightgreen default ~G
color index_flags yellow default ~N
color index_author blue brightred ~F
color index_author black green '%f Bekannte'
color index_author black red '%f Work'
color index_number green default
color index_date cyan default
color index_size cyan default
color header brightcyan default '^From:'
color header brightcyan default '^Subject:'
color header black brightgreen '^User-Agent:.*Mutt'
color body brightwhite default "([0-2][0-9]|[0-9]|[1-2][0-9]):[0-5][0-9](:[0-5][0-9])?"
color body brightwhite default "([0-3])?[0-9]\\.([0-1])?[0-9]\\.([1-2][0-9])?[0-9][0-9]"
color body brightgreen default "(^| )_[[:print:]]+_[ \n]"
color body brightred default "(^| )\\*[[:print:]]+\\*[,.?!]?[ \n]"
color body brightdefault default "^[[:blank:]]*-[[:print:]]+$"
color body brightdefault default "^[[:blank:]]*\\*[[:print:]]+$"
color body brightdefault blue "^=+[[:print:]]+$"
color body default blue "^===+$"
color body default blue "^---+$"
color body brightdefault blue "^#+[[:print:]]+$"
color quoted magenta default
color quoted1 red default
color quoted2 green default
color quoted3 magenta default
color quoted4 blue default
color quoted5 cyan default
color quoted6 green default
color quoted7 red default
color quoted8 magenta default
color quoted9 blue default
# vim ft=conf
text/html; w3m -I %{charset} -T text/html; copiousoutput;
# -- MAIN --
set realname="Daniel Duclos-Cavalcanti"
set from="daniel.duclos.cavalcanti@gmail.com"
set imap_user = "daniel.duclos.cavalcanti@gmail.com"
set imap_pass = `pass show mutt`
# smtp[s]://[user[:pass]@]host[:port]
set smtp_url="smtps://daniel.duclos.cavalcanti@gmail.com@smtp.gmail.com:465/"
set smtp_pass = `pass show mutt`
set smtp_authenticators='gssapi:login'
# -- MAILBOXES AND FOLDERS --
set sort=reverse-date
set sort_aux=last-date-received
# temporary files
set tmpdir=/tmp
# in case notmuch is being used
# notmuch://<absolute path>.
# set nm_default_uri = "notmuch:///home/user/.mail"
# set nm_record = yes
# mailbox type and location
# set mbox_type=Mail
set folder=imaps://imap.gmail.com:993
set spoolfile = "+INBOX"
set postponed = "+Drafts" # drafts
set record = "+Sent" # outgoing messages
set trash = "+Trash" # trash
# The mailboxes specifies folders which can receive mail and which will
# be checked for new messages. When changing folders, pressing space will
# cycle through folders with new mail.
unmailboxes *
mailboxes =INBOX =[Gmail]/Sent\ Mail =[Gmail]/Drafts =[Gmail]/Spam =[Gmail]/Trash
# mailboxes +Drafts +Sent +Spam
# Using my_hdr, you can define headers which will be added to the messages
# composed
# unmy_hdr *
# my_hdr X-Location: Europe, Germany
set editor = "nvim -c set wrap"
set mailcap_path = ~/.config/neomutt/mailcap
auto_view text/html
alternative_order text/plain text/enriched text/html
# When set along with $edit_headers, NeoMutt will skip the initial
# send-menu (prompting for subject and recipients) and allow you to
# immediately begin editing the body of your message.
set autoedit = no
set sleep_time=0
# GNU's spell-checking software
# set ispell="ispell"
# set ispell="aspell -e -c"
# This is the string that will precede a message which has been included in
# a reply.
# set attribution = "On %d, %n wrote:"
# This variable controls the default subject when forwarding a message.
# set forward_format = "[%a: %s]"
# set signature = "~/.config/neomutt/signature"
# This variable specifies the subject to be used when replying to an email
# with an empty subject.
set empty_subject = "Re: your mail"
# -- FORMATTING --
# %a Address of the author
# %A Reply-to address (if present; otherwise: address of author)
# %b Filename of the original message folder (think mailbox)
# %B The list to which the letter was sent, or else the folder name (%b).
# %C Current message number
# %c Number of characters (bytes) in the message
# %D Date and time of message using date_format and local timezone
# %d Date and time of message using date_format and sender's timezone
# %e Current message number in thread
# %E Number of messages in current thread
# %F Author name, or recipient name if the message is from you
# %f Sender (address + real name), either From: or Return-Path:
# %g Newsgroup name (if compiled with NNTP support)
# %g Message tags (e.g. notmuch tags/imap flags)
# %Gx Individual message tag (e.g. notmuch tags/imap flags)
# %H Spam attribute(s) of this message
# %I Initials of author
# %i Message-id of the current message
# %J Message tags (if present, tree unfolded, and != parent's tags)
# %K The list to which the letter was sent (if any; otherwise: empty)
# %L If an address in the “To:” or “Cc:” header field matches an address Defined by the users “subscribe” command, this displays "To <list-name>", otherwise the same as %F
# %l Number of lines in the message (does not work with maildir, Mh, and possibly IMAP folders)
# %M Number of hidden messages if the thread is collapsed
# %m Total number of message in the mailbox
# %N Message score
# %n Author's real name (or address if missing)
# %O Original save folder where NeoMutt would formerly have Stashed the message: list name or recipient name If not sent to a list
# %P Progress indicator for the built-in pager (how much of the file has been displayed)
# %q Newsgroup name (if compiled with NNTP support)
# %R Comma separated list of “Cc:” recipients
# %r Comma separated list of “To:” recipients
# %S Single character status of the message (“N”/“O”/“D”/“d”/“!”/“r”/“*”)
# %s Subject of the message
# %T The appropriate character from the $to_chars string
# %t “To:” field (recipients)
# %u User (login) name of the author
# %v First name of the author, or the recipient if the message is from you
# %W Name of organization of author (“Organization:” field)
# %x “X-Comment-To:” field (if present and compiled with NNTP support)
# %X Number of MIME attachments (please see the “attachments” section for possible speed effects)
# %Y “X-Label:” field, if present, and (1) not at part of a thread tree, (2) at the top of a thread, or (3) “X-Label:” is different from Preceding message's “X-Label:”
# %y “X-Label:” field, if present
# %Z A three character set of message status flags.
# %zc Message crypto flags
# %zs Message status flags
# %zt Message tag flags
# %{fmt} the date and time of the message is converted to sender's time zone, and “fmt” is expanded by the library function strftime(3); a leading bang disables locales
# %[fmt] the date and time of the message is converted to the local time zone, and “fmt” is expanded by the library function strftime(3); a leading bang disables locales
# %(fmt) the local date and time when the message was received. “fmt” is expanded by the library function strftime(3); a leading bang disables locales
# %>X right justify the rest of the string and pad with character “X”
# %|X pad to the end of the line with character “X”
# %*X soft-fill with character “X” as pad
set index_format="%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s"
# %b Number of mailboxes with new mail *
# %d Number of deleted messages *
# %f The full pathname of the current mailbox
# %F Number of flagged messages *
# %h Local hostname
# %l Size (in bytes) of the current mailbox *
# %L Size (in bytes) of the messages shown (i.e., which match the current limit) *
# %m The number of messages in the mailbox *
# %M The number of messages shown (i.e., which match the current limit) *
# %n Number of new messages in the mailbox *
# %o Number of old unread messages *
# %p Number of postponed messages *
# %P Percentage of the way through the index
# %r Modified/read-only/won't-write/attach-message indicator, According to $status_chars
# %R Number of read messages *
# %s Current sorting mode ($sort)
# %S Current aux sorting method ($sort_aux)
# %t Number of tagged messages *
# %u Number of unread messages *
# %v NeoMutt version string
# %V Currently active limit pattern, if any *
# %>X Right justify the rest of the string and pad with “X”
# %|X Pad to the end of the line with “X”
# %*X Soft-fill with character “X” as pad
set status_format = "-%r-NeoMutt: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-"
# Specifies the format of the data displayed for the ``alias'' menu. The
# following printf(3)-style sequences are available:
# %a Alias name
# %f Flags - currently, a ``d'' for an alias marked for deletion
# %n Index number
# %r Address which alias expands to
# %t Character which indicates if the alias is tagged for inclusion
set alias_format="%4n %2f %t %-10a %r"
# This variable allows you to customize the sidebar display. This string is
# similar to $index_format, but has its own set of printf(3)-like
# sequences:
# %B Name of the mailbox
# %S * Size of mailbox (total number of messages)
# %N * Number of unread messages in the mailbox
# %n N if mailbox has new mail, blank otherwise
# %F * Number of Flagged messages in the mailbox
# %! “!” : one flagged message; “!!” : two flagged messages; “n!” : n flagged messages (for n > 2). Otherwise prints nothing.
# %d * @ Number of deleted messages
# %L * @ Number of messages after limiting
# %t * @ Number of tagged messages
# %>X right justify the rest of the string and pad with “X”
# %|X pad to the end of the line with “X”
# %*X soft-fill with character “X” as pad
# * = Can be optionally printed if nonzero @ = Only applicable to the current folder
#
# In order to use %S, %N, %F, and %!, $mail_check_stats must be set. When
# thus set, a suggested value for this option is "%B%?F? [%F]?%*
# %?N?%N/?%S".
set sidebar_format = "%B%?F? [%F]?%* %?N?%N/?%S"
# -- SIDERBAR --
set sidebar_visible = yes
set sidebar_width = 50
set sidebar_delim_chars='/'
set sidebar_component_depth=2
set sidebar_divider_char='|'
# -- ALIASES --
set alias_file="~/.config/neomutt/aliases"
set reverse_alias=no
set sort_alias=alias
source "~/.config/neomutt/aliases"
# -- BINDINGS --
source "~/.config/neomutt/bindings"
# -- COLORS --
source "~/.config/neomutt/colors"
# -- ENCRYPTION --
# use gpgme code for S/MIME and PGP encryption
set crypt_use_gpgme
# This is the default key-pair to use for PGP operations. It will be used
# for encryption.
# set pgp_default_key = "0x12345678"
set crypt_autoencrypt = no
set crypt_autosign = no
set crypt_use_gpgme = yes
# set crypt_replyencrypt = yes, encrypt replies to PGP emails by default
# -- QUERY --
# neomutt will use this command to make external address queries
# set query_command="/usr/bin/lbdbq '%s'"
# -- HOOKS --
# folder-hook
# mbox-hook
# message-hook
# reply-hook
# send-hook
# send-hook
# crypt-hook
# for questions go to
# https://github.com/neomutt/samples/blob/main/config/neomuttrc-example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment