Add a working neomutt configuration

This commit is contained in:
Orien Vandenbergh 2025-04-16 13:40:55 -04:00
parent 405e4059cd
commit 6a923426b0
18 changed files with 405 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
neomutt/accounts

33
neomutt/accounts.sample Normal file
View File

@ -0,0 +1,33 @@
set imap_user = "<username>@guidepointsecurity.com"
# set imap_pass = <password>
set smtp_url = "smtps://<username>@guidepointsecurity.com@smtp.gmail.com:465/"
# set smtp_pass = $imap_pass
set ssl_force_tls = yes
# Pull a copy of this script:
# https://github.com/google/gmail-oauth2-tools/blob/master/python/oauth2.py
# I saved mine as ~/bin/mutt-gmail-oauth2.py
#
# Follow their instructions, summarized below
#
# Set up a client of type 'Web Application', while signed into gps, here:
# https://console.developers.google.com/apis/credentials
#
# Authenticate and collect your refresh token with this command
# mutt-gmail-oauth2.py --user='<username>@guidepointsecurity.com' \
# --client_id='<clientid>' \
# --client_secret='<clientsecret>' \
# --generate_oauth2_token
#
# Then put the pieces together in the below 'refresh_command'
set imap_authenticators="oauthbearer"
set imap_oauth_refresh_command="~/bin/mutt-gmail-oauth2.py --quiet\
--user='<username>@guidepointsecurity.com'\
--client_id='<clientid>'\
--client_secret='<clientsecret>'\
--refresh_token='<refreshtoken>'"
set smtp_authenticators=${imap_authenticators}
set smtp_oauth_refresh_command=${imap_oauth_refresh_command}

0
neomutt/aliases Normal file
View File

28
neomutt/auto_views Normal file
View File

@ -0,0 +1,28 @@
# -*- muttrc -*-
#
# Tell mutt which MIME types to auto-view
#
auto_view application/zip
auto_view application/x-gzip
auto_view application/x-gunzip
auto_view application/pgp-signature
auto_view application/pgp
auto_view application/octet-stream
auto_view application/x-zip-compressed
auto_view application/x-arj-compressed
auto_view application/x-tar-gz
auto_view application/ms-tnef
auto_view application/x-perl
auto_view application/x-sh
auto_view application/x-tcl
auto_view application/x-delphi-source
auto_view application/emacs-lisp
auto_view application/msword
auto_view text/x-patch
auto_view text/html
auto_view text/x-vcard
auto_view text/x-script.elisp
auto_view text/x-lisp
auto_view text/x-diff
auto_view image/tiff

12
neomutt/bindings Normal file
View File

@ -0,0 +1,12 @@
# -*- muttrc -*-
#
# bindings for mutt.
# Pager bindings
bind pager <down> next-line
bind pager <up> previous-line
bind pager / search
bind pager 0 top
bind pager G bottom
bind pager g group-reply

64
neomutt/colours Normal file
View File

@ -0,0 +1,64 @@
# -*- muttrc -*-
#
# Colour settings for mutt.
#
# Default colour definitions
color hdrdefault cyan black
color quoted red black
color signature blue brightblack
color indicator brightwhite black
color attachment green black
color error red black
color message yellow black
color search brightwhite magenta
color status green brightblack
color tree red black
color normal white black
color tilde blue black
color bold yellow black
color markers red black
# Colour definitions when on a mono screen
mono bold bold
mono underline underline
mono indicator reverse
# Colours for items in the reader
color header brightcyan black "^(From|Subject):"
#color header red black "^X-Junked-Because: "
#color header red black "^X-Virus-hagbard: .* FOUND"
mono header bold "^(From|Subject|X-Junked-Because|X-Virus-hagbard):"
# Colours for items in the index
color index white black ~N
color index brightblue black "~N (~e guidepointsecurity\.com | ~h \"^In-[Rr]eply-[Tt]o: .*guidepointsecurity\.com\")"
color index red black ~F
color index green black ~T
color index blue black ~D
mono index bold ~N
mono index bold ~F
mono index bold ~T
mono index bold ~D
# Highlights inside the body of a message.
# URLs
color body brightblue black "(http|https|ftp|news|telnet|finger)://[^ \">\t\r\n]*"
color body brightblue black "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"
color body brightblue black "news:[^ \">\t\r\n]*"
mono body bold "(http|https|ftp|news|telnet|finger)://[^ \">\t\r\n]*"
mono body bold "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"
mono body bold "news:[^ \">\t\r\n]*"
# email addresses
color body brightblue black "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"
mono body bold "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"
# Various smilies and the like
color body brightgreen black "<[Gg]>" # <g>
color body brightgreen black "<[Bb][Gg]>" # <bg>
color body brightgreen black " [;:]-*[)>(<|]" # :-) etc...
color body brightblue black "(^|[[:space:]])\\*[^[:space:]]+\\*([[:space:]]|$)" # *Bold* text.
color body brightblue black "(^|[[:space:]])_[^[:space:]]+_([[:space:]]|$)" # _Underlined_ text.
color body brightblue black "(^|[[:space:]])/[^[:space:]]+/([[:space:]]|$)" # /Italic/ text.

0
neomutt/fcc-hooks Normal file
View File

0
neomutt/folder-hooks Normal file
View File

26
neomutt/headers Normal file
View File

@ -0,0 +1,26 @@
# -*- muttrc -*-
#
# Configure header displays.
#
# Ignore all headers
ignore *
# Then un-ignore the ones I want to see
unignore From:
unignore To:
unignore Reply-To:
unignore Mail-Followup-To:
unignore Subject:
unignore Date:
unignore Organization:
unignore Newsgroups:
unignore CC:
unignore BCC:
unignore Message-ID:
unignore X-Mailer:
unignore User-Agent:
unignore X-Spam-Status:
# Now order the visable header lines
hdr_order Date: From: To: CC: BCC: Subject: Reply-To: Mail-Followup-To: Organization: User-Agent: X-Mailer:

View File

@ -0,0 +1,56 @@
Here's what I do. I'm using neomutt. I don't recall whether that's important for this procedure or not.
In my muttrc I have this line:
macro compose K "<pipe-message>$HOME/.mutt/make-alternative.sh<enter><attach-file>/tmp/neomutt-alternative.html<enter><tag-entry><previous-entry><tag-entry><group-alternatives>"
That make-alternative.sh file is this:
#!/usr/bin/env bash
# Juice is https://www.npmjs.com/package/juice
# So expects to be installed via `sudo npm i -g juice`
juice <(pandoc --standalone --template=$HOME/.mutt/template.html --from=commonmark --to=html) /tmp/neomutt-alternative.html
As you can see from the command, it relies on pandoc and juice. pandoc is used to convert from markdown (I like Commonmark so I've told it to use that dialect) to HTML.
The juice binary is installed as mentioned in the comment. It inlines CSS to the HTML tags. That CSS is in the template.html file which is also referenced, and contains this:
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>-</title>
<style>
img {
max-width: 100%;
}
blockquote {
/* These styles are copied from what Gmail sends */
margin: 0px 0px 0px 0.8ex;
border-left: 1px solid rgb(204,204,204);
padding-left: 1ex;
}
</style>
</head>
<body>
$body$
</body>
</html>
As commented there, the blockquote style is pulled from what Gmail sends in its emails. I presume I added that (this is years ago) because the default stood out like a sore thumb, or something.
For usage, in the compose window (that's after you save and close the message editor, where you can see all the from and to and subject and attachments), I make sure the text/plain attachment is highlighted and I press K. That runs the macro. It runs the plain text through pandoc, adds the HTML version, then selects both and makes them a multipart/alternative group.
What I like:
When I've made a long complicated email with headings and lists and stuff I can use this macro before sending, and I know it'll be readable and won't get screwed up when forwarded or in quoted replies etc. Especially important if it's a list of questions and I'm expecting someone to reply to each inline.
It doesn't care about what I use to actually send the mail, so no sendmail/SMTP reconfiguration is necessary.
What I don't like:
Once I've run the macro, as far as I can tell (neo)mutt provides no way to ungroup the alternatives, or for me to edit/split them. So there's no way to undo, as far as I know. That means I have to know I'm finished and won't need to edit again before I run it.

50
neomutt/macros Normal file
View File

@ -0,0 +1,50 @@
# -*- muttrc -*-
#
# macros for mutt.
# Macros for use in the index.
macro index "\Cx\Cb" "<change-folder>?" # Folder list.
macro index "\Cx\Cs" "<pipe-message>cat > ~/" # Save message
macro index "\'" "<clear-flag>r" # Mark as un-replied
macro index "y" "<sync-mailbox><change-folder>?<toggle-mailboxes>" # "-y" screen
macro index "\Cb" "<pipe-message>urlview<enter>" # URL viewer.
#macro index "\ea" "<change-folder>=archives/<tab><tab>" # List archives
#macro index "\eb" "<pipe-message>lbdb-fetchaddr<enter>" # Store address details in lbdb.
macro index "\eh" "<pipe-message>mutt-mailhops|most<enter>" # View the path of the mail.
macro index "\ef" "<pipe-message>view-x-face<enter>" # View the X-Face (if there is one).
macro index "\ev" "<pipe-message>less<enter>" # View the message in less.
macro index "\Cs\Co" "<limit>~h \"X-SpamProbe: GOOD\"<enter><last-entry>" # View good emails.
macro index "\Cs\Cs" "<limit>~h \"X-SpamProbe: SPAM\"<enter><last-entry>" # View bad emails.
macro index \Cr ":source ~/.muttrc<enter>" "Re-source the muttrc"
# Macros for use in the pager.
macro pager "w" "<enter-command>set invsmart_wrap invmarkers<enter>" # Toggle wrap stuff
macro pager "y" "<sync-mailbox><change-folder>?<toggle-mailboxes>" # "-y" screen
macro pager "\e1" "<enter-command>set pager_index_lines=1<enter>" # Change PIL size
macro pager "\e2" "<enter-command>set pager_index_lines=2<enter>" # Change PIL size
macro pager "\e3" "<enter-command>set pager_index_lines=3<enter>" # Change PIL size
macro pager "\e4" "<enter-command>set pager_index_lines=4<enter>" # Change PIL size
macro pager "\e5" "<enter-command>set pager_index_lines=5<enter>" # Change PIL size
macro pager "\e6" "<enter-command>set pager_index_lines=6<enter>" # Change PIL size
macro pager "\e7" "<enter-command>set pager_index_lines=7<enter>" # Change PIL size
macro pager "\e8" "<enter-command>set pager_index_lines=8<enter>" # Change PIL size
macro pager "\e9" "<enter-command>set pager_index_lines=9<enter>" # Change PIL size
macro pager "\e0" "<enter-command>set pager_index_lines=0<enter>" # Change PIL size
macro pager "\Cb" "<pipe-message>urlview<enter>" # URL viewer.
macro pager "\Cx\Cb" "<change-folder>?" # Folder list.
macro pager "\Cx\Cs" "<pipe-message>cat > ~/" # Save message
#macro pager "\eb" "<pipe-message>lbdb-fetchaddr<enter>" # Store address details in lbdb.
macro pager "\eh" "<pipe-message>mutt-mailhops|most<enter>" # View the path of the mail.
macro pager "\ef" "<pipe-message>view-x-face<enter>" # View the X-Face (if there is one).
macro pager "\ev" "<pipe-message>less<enter>" # View the message in less.
macro pager "\el" "<enter-command>set invpipe_decode<enter>\
<pipe-message>linkify|w3m -T text/html<enter><enter-command>\
set invpipe_decode<enter>" # View the message in w3m.
#macro pager "\Cs\Cs" "<pipe-message>spamprobe -T score<enter>" # What's the score for this message?
#macro pager "\Cs\Cj" "<pipe-message>spamprobe spam<enter>" # This message is junk.
#macro pager "\Cs\Cg" "<pipe-message>spamprobe good<enter>" # This message is good.
# Provide some "on-line" help.
macro generic "\e?" "<shell-escape>less /usr/share/doc/mutt/manual.txt<enter>"
macro index "\e?" "<shell-escape>less /usr/share/doc/mutt/manual.txt<enter>"
macro pager "\e?" "<shell-escape>less /usr/share/doc/mutt/manual.txt<enter>"

24
neomutt/mailboxes Normal file
View File

@ -0,0 +1,24 @@
# -*- muttrc -*-
#
# Mailboxes for mutt
#
# Where are mailboxes stored
set folder="imaps://imap.gmail.com/"
# Where archived mail goes
set mbox="+[Gmail]/All Mail"
#set mbox="imaps://imap.gmail.com/[Gmail]/All Mail"
# Where postponed messaged die
set postponed="+[Gmail]/Drafts"
# ... and it gets saved in =outbox.
set record="+[Gmail]/Sent Mail"
# Look me up
set spoolfile="+INBOX"
mailboxes "+INBOX"
set imap_check_subscribed = yes
#mailboxes "imaps://imap.gmail.com/AdminTickets"

9
neomutt/mailcap Normal file
View File

@ -0,0 +1,9 @@
text/vcard; mutt_vcard_filter; copiousoutput
text/html; w3m -dump %s; copiousoutput; nametemplate=%s.html
application/x-html; w3m -dump %s; copiousoutput; nametemplate=%s.html
image/jpeg; gthumb %s;
application/octet-stream; mutt-octet-filter %s; copiousoutput
text/x-diff; view %s; needsterminal
text/x-patch; view %s; needsterminal
application/x-gzip; zcat %s; copiousoutput
application/msword; soffice %s;

15
neomutt/message-hooks Normal file
View File

@ -0,0 +1,15 @@
# -*- muttrc -*-
#
# Fine tune mutt depending on aspects of a message.
#
# By default, don't do anything clever.
message-hook . "unset display_filter"
# Sort out silly characters from Microsoft MUAs or MUAs that suffer the same
# problems.
message-hook "~h \"X-Mailer: (Microsoft Outlook IMO|Experian ContactMail)\"" "set display_filter='tr \\\\200\\\\202\\\\221\\\\222\\\\223\\\\224\\\\225\\\\226\\\\227 \\\\244\\\\054\\\\140\\\\047\\\\042\\\\042\\\\052\\\\055\\\\055'"
# IncrediMail, whatever the hell that is, sends out its text alternative as
# DOS formatted text. Clean things up.
message-hook "~h \"X-Mailer: IncrediMail" "set display_filter='tr -d \\\\r'"

81
neomutt/neomuttrc Normal file
View File

@ -0,0 +1,81 @@
set realname="Orien Vandenbergh"
set signature="~/.signature.txt"
set from="orien.vandenbergh@guidepointsecurity.com"
set use_from = yes
set envelope_from = yes
set hostname=felurian.guidepointsecurity.com # Name of the localhost
set hidden_host # Hide host details
set alias_file=~/.config/neomutt/aliases # Personal mail aliases
#set query_command="~/bin/mutt-ldap '%s'" # How to query the company contacts
set postpone=ask-no # Ask about postponing
set move # Keep read mail in inbox
set print=ask-no # Ask before printing
set delete=yes # Just delete it
set include # Include messages in replies
set sort_aux=date-received # Sort threads by date received
set charset=utf-8 # UTF-8 by default
#set noallow_8bit # 8bit isn't safe via Demon.
# Attribution line.
set attribution="* %n <%a> [%{%Y-%m-%d %H:%M:%S %Z}]:\n"
set edit_headers # I want to edit the message headers.
# Use emacs.
#set editor="emacs -geometry 90x73+298+0 --load post-mode"
set editor="vim -c ':0' -c '/^$/' -c ':nohlsearch'"
#set query_command="lbdbq '%s'" # Use the little brother database for doing queries.
#set nomark_old # Don't mark unread new msgs as old.
set mail_check=90
set timeout=15
set mbox_type=maildir # mailbox type
set mbox="!" # Default mailbox.
#set imap_user="orien" # How we gonna log in
#set imap_peek="no" # Mark a message as read, when downloaded
set copy # Keep copies of outgoing mail...
set nobeep # We don't need no beeping software.
set nosmart_wrap # Don't want smart wrapping.
set nomarkers # Don't want any wrap markers.
set mime_forward # Forward message as MIME attachments.
set pager_context=3 # Display 3 lines of context in pager.
set nostrict_threads # Lets have some fuzzy threading.
set sendmail_wait=-1 # Don't wait around for sendmail.
set wait_key=no # Don't wait after subshell exit
set fcc_clear # Keep fcc's clear of signatues and encryption.
set nopipe_decode # Don't decode messages when piping.
# Print via a2ps
set print_command="a2ps -1gEmail --borders=no --strip=3"
set tilde # Fill out messages with '~'.
set read_inc=100 # Read counter ticks every 100 msgs.
set write_inc=100 # Write counter ticks every 100 msgs.
set noconfirmappend # Just append, don't hassle me.
set pager_stop # Don't skip msgs on next page.
# Where to find the mailcap.
set mailcap_path=~/.config/neomutt/mailcap:/usr/local/etc/mailcap:/etc/mailcap
# What we consider to be a quote.
set quote_regexp="^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
set to_chars=" +TCFL" #
set header_cache="~/.cache/neomutt/headers" # Where to cache imap headers
set message_cachedir="~/.cache/neomutt/bodies" # "" bodies
#source /usr/share/doc/mutt/samples/gpg.rc # Use GPG
source ~/.config/neomutt/accounts # Account details
source ~/.config/neomutt/aliases # Load in my aliases.
source ~/.config/neomutt/auto_views # Define auto_views.
source ~/.config/neomutt/bindings # Define key bindings.
source ~/.config/neomutt/colours # Define colours.
source ~/.config/neomutt/fcc-hooks # Define fcc-hooks.
source ~/.config/neomutt/folder-hooks # Define folder-hooks.
source ~/.config/neomutt/headers # Configure header display.
source ~/.config/neomutt/macros # Define macros.
source ~/.config/neomutt/mailboxes # Define the list of folders that receive mail.
source ~/.config/neomutt/message-hooks # Define message hooks.
source ~/.config/neomutt/non-standard # Support for mutt patches.
source ~/.config/neomutt/save-hooks # Define save-hooks.
source ~/.config/neomutt/subscriptions # Define the list of subscribed mailing lists.
# HTML is the last option.
alternative_order text/enriched text/plain text/html
# Last, but not least, get mutt to display its version on startup.
# This conflicts with password prompts, so leaving off
#push <show-version>

0
neomutt/non-standard Normal file
View File

6
neomutt/save-hooks Normal file
View File

@ -0,0 +1,6 @@
# -*- muttrc -*-
#
# Configure where things get saved to.
#
#save-hook .* =Archive/`date "+%Y"`/`date "+%m"`

0
neomutt/subscriptions Normal file
View File