Compare commits

...

6 commits

Author SHA1 Message Date
1a6b929e24
neomutt: Update message index colors
We have differentiated views of new (italic) and unread (underline, and
a bit of highlight on the author) messages.

Additionally the indicator highlighting works better with the rest of
the colors, and we have a better paperclip icon icon for attachments.
2025-09-16 21:28:32 +02:00
b02d0218c4
neomutt: Automatically mark seen messages old
E-Mails have 2-staged flag options for levels of 'seen':
Unseen/Seen and Unread/Read.

A message is unseen if it has arrived since the last time we had mutt
open. We do not have to have had the actual message open for it to be
marked seen (or 'old'). In other words, whichever messages we have seen
once on the index alone are not 'new' to us anymore, they have been
seen.

On the other hand, a message is only read if it is actually opened. So
even if we have seen it on the index page, or moved it to a different
mailbox or anything else, it can still be unread if we did not open it.
Additionally, I have it set up now so that the message only gets set to
'read' by neomutt after it has been open for 1 second.

This gives a tiny grace period if we are scrubbing through mails or
accidentally opened one we did not want.
2025-09-16 21:28:32 +02:00
3abc92ac08
neomutt: Format settings 2025-09-16 21:28:31 +02:00
79a9c4a227
neomutt: Rename render-prettyhtml to neomutt-renderhtml
Also ensure the temporary file

a) is always different, by using mktemp
and b) is always deleted with an EXIT trap
2025-09-16 21:28:31 +02:00
6b2a0e1918
neomutt: Ignore khard deprecation warnings 2025-09-16 21:28:30 +02:00
519e4ba803
neomutt: Add attaching/saving files with file manager 2025-09-16 21:28:30 +02:00
8 changed files with 204 additions and 122 deletions

View file

@ -1,15 +1,15 @@
# Account settings
# local maildir settings
set mbox_type = Maildir
set folder = ~/documents/mail # This has the shortcut '+' or '='
set spoolfile = "+Inbox" # This has the shortcut '!'
set postponed = "+Drafts"
set record = "+Sent"
set trash = "+Trash"
mailboxes ! \
"+Sent" \
"+Drafts" \
"+Trash" \
"+Archive" \
"+Junk"
set mbox_type = Maildir
set folder = ~/documents/mail # This has the shortcut '+' or '= '
set spool_file = "+Inbox" # This has the shortcut '!'
set postponed = "+Drafts"
set record = "+Sent"
set trash = "+Trash"
mailboxes -notify -poll ! \
-poll "+Archive" \
-poll "+Jobs" \
-poll "+Receipts" \
-nonotify -nopoll "+Junk" \
-nonotify -nopoll "+Sent" \

View file

@ -5,36 +5,6 @@ color header brightmagenta default "^(From)"
color header brightcyan default "^(Subject)"
color header brightwhite default "^(CC|BCC)"
# mono bold bold
# mono underline underline
# mono indicator reverse
# mono error bold
# color normal default default
# color indicator brightyellow default # currently selected message. default makes bar clear, disabled arrow to save space.
# color sidebar_highlight red default
# color sidebar_divider brightblack black
# color sidebar_flagged red black
# color sidebar_new green black
# color normal brightyellow default
# color error red default
# color tilde black default
# color message cyan default
# color markers red white
# color attachment white default
# color search brightmagenta default
# color status brightyellow black
# color hdrdefault brightgreen default
# color quoted green default
# color quoted1 blue default
# color quoted2 cyan default
# color quoted3 yellow default
# color quoted4 red default
# color quoted5 brightred default
# color signature brightgreen default
# color bold black default
# color underline black default
# color normal default default
color body brightred default "[\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+" # Email addresses
color body brightblue default "(https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+" # URL
color body green default "\`[^\`]*\`" # Green text between ` and `
@ -56,15 +26,20 @@ mono body bold "^gpg: BAD signature from.*"
color body red default "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a-f][0-9a-f])*@)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?|[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(:[0-9]+)?)|([a-z0-9_.!~*'()$,;:@&=+-]|%[0-9a-f][0-9a-f])+)(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?(#([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?|(www|ftp)\\.(([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?(:[0-9]+)?(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?(#([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?)[^].,:;!)? \t\r\n<>\"]"
# Default index colors:
color index yellow default '.*'
color index_author red default '.*'
color index_number blue default
color index_subject cyan default '.*'
color index yellow default "~A"
color index_author magenta default "~A"
color index_number blue default "~A"
color index_subject cyan default "~A"
# For new mail:
color index brightyellow brightblack "~N"
color index_author brightred brightblack "~N"
color index_subject brightcyan black "~N"
# For new mail (i.e. arrived after last time neomutt was open):
color index brightyellow default "~N"
color index_author bold italic brightred default "~N"
color index_subject bold italic brightcyan default "~N"
# For unread mail:
color index brightyellow default "~U"
color index_author bold brightmagenta brightblack "~U"
color index_subject underline brightcyan default "~U"
color progress black cyan
# Nerd icons idea based on https://github.com/sheoak/neomutt-powerline-nerdfonts/
@ -73,13 +48,13 @@ color progress black cyan
# Formatting ----------------------------------------------------------------------
set date_format = "%a %d %h %H:%M"
set index_format=" %zc %zs %zt | %-35.35L %?X?📎& ? %M %-30.100s %> %?Y?%Y ? %(!%a %d %h %H:%M) "
set index_format=" %zc %zs %zt | %-35.35L %?X?& ? %M %-30.100s %> %?Y?%Y ? %(!%a %d %h %H:%M) "
set pager_format="%n %T %s%*  %{!%d %b · %H:%M} %?X? %X?%P"
set status_format = " %D %?u? %u ?%?R? %R ?%?d? %d ?%?t? %t ?%?F? %F ?%?p? %p? \n \n"
set compose_format="-- NeoMutt: Compose [Approx. msg size: %l Atts: %a]%>-"
# set vfolder_format = "%N %?n?%3n& ? %8m  · %f"
set attach_format = "%u%D  %T %-75.20d %T  %5s %m/%M"
set sidebar_format = '%D%?Z? [%Z]?%* %?S?%S?'
set sidebar_format = '%B%<F? [%F]>%* %<Z?%Z/>%S'
index-format-hook attachment_info '=B text/calendar ~X 1' ' '
index-format-hook attachment_info '=B text/calendar' " "
index-format-hook attachment_info '~X 1' " "
@ -126,7 +101,7 @@ color index color3 default '~T' # tagged messages
color index color3 default '~T~N' # tagged messages (new)
color index color11 default '~T~R' # tagged messages (read)
color tree color8 color8 # thread tree lines/arrow
color indicator default color8 # selection indicator
color indicator black cyan # selection indicator
color index_date color8 default # date is always the same colour
color index_label color6 default # label is always the same colour
@ -139,7 +114,6 @@ color sidebar_divider color8 black # divider between sidebar & content
color sidebar_flagged red black # mailboxes containing flagged mail
color sidebar_new green black # mailboxes containing new mail
color sidebar_unread color7 default # mailboxes containing unread mail
color sidebar_unread color7 default # mailboxes containing unread mail
# Message Headers -----------------------------------------------------------------

View file

@ -2,7 +2,7 @@
text/html; open %s ; nametemplate=%s.html
# render html emails inline using magic (uncomment the line below to use lynx instead)
# text/html; lynx -assume_charset=%{charset} -display_charset=utf-8 -collapse_br_tags -dump %s; nametemplate=%s.html; copiousoutput
text/html; render-prettyhtml %s; nametemplate=%s.html; copiousoutput;
text/html; neomutt-renderhtml %s; nametemplate=%s.html; copiousoutput;
text/plain; $EDITOR %s ;
# show calendar invites

View file

@ -74,6 +74,10 @@ bind pager G bottom
# markdown to html for composition
macro compose ,m "F pandoc -s -f markdown -t html \ny^T^Utext/html; charset=UTF-8\n" "Convert from MD to HTML"
# attach and save file attachments
macro compose a '<enter-command>source "neomutt-filer attach"|<enter>' "Attach with file manager"
macro attach s '<enter-command>source "neomutt-filer saveto"|<enter>' "Save attachment to dir"
# since we unbound the original g
bind index,pager r noop # to avoid accidentally sending replies
bind index,pager rr group-reply

View file

@ -3,4 +3,3 @@ source settings
source maps
source account

View file

@ -1,96 +1,126 @@
set mail_check = 60
set mail_check_stats
set quit # at least for rapid prototyping
set sleep_time = 0 # no pause for info messages
set mark_old = no # things should only be new/unread or I actually looked at them
set pager_read_delay = 3 # mark read after 3 sec
set pipe_decode # get rid of headers when passing messages along
set auto_tag # apply commands to all tagged messages automatically
set wait_key = no # don't wait for user input after shell cmds, auto-view, piping, etc
set thorough_search = no # don't pre-process mail for ~b/~B searches
set flag_safe # make it impossible to delete flagged mails
# Pager settings
# filetypes and mailcap
# at least for rapid prototyping
set quit
# no pause for info messages
set sleep_time = 0
# mark read (not just seen) after
set pager_read_delay = 1
# get rid of headers when passing messages along
set pipe_decode
# apply commands to all tagged messages automatically
set auto_tag
# dont wait for user input after shell cmds, auto-view, piping, etc
set wait_key = no
# dont pre-process mail for ~b/~B searches
set thorough_search = no
# make it impossible to delete flagged mails
set flag_safe
################### Pager settings
# filetypes and mailcap
set mailcap_path = "~/.config/neomutt/mailcap:~/.mailcap:/usr/share/neomutt/mailcap:/etc/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap"
# Consult mime.types for determining types of these attachments
# Consult mime.types for determining types of these attachments
mime_lookup application/octet-stream
# This requires a ~/.mailcap entry with the copiousoutput flag, such as:
# text/html; lynx -dump -width ${COLUMNS:-80} %s; nametemplate=%s.html; copiousoutput
# Prefer plain text to html but multipart to plain for those only sending that
# This requires a ~/.mailcap entry with the copiousoutput flag, such as:
# text/html; lynx -dump -width ${COLUMNS:-80} %s; nametemplate=%s.html; copiousoutput
auto_view application/ics
auto_view text/calendar
auto_view text/plain
auto_view text/html
alternative_order text/calendar application/ics text/plain text/enriched text/html text/* multipart/mixed multipart/related text/plain
set count_alternatives = yes # look for attachments also in multipart/alternatives
# Remember to `mkdir -p ~/.neomutt/hcache` first:
set header_cache= "~/.neomutt/hcache"
# Compose settings
set edit_headers # allow editing headers while writing mail
set sig_dashes # separate signature from mail
set fast_reply # automatically fill in from and subject for replies
set forward_format = "Fwd: %s"
set reply_to # default send back to reply-to: header instead of from: header
set reverse_name # default to reply as person e-mail was originally sent to
set include # include original msg in reply
set forward_quote # include original msg as quote in fwd
set forward_format = "FW: %s" # subject for forwarding
set mime_forward = no # forward attachments with mail
set fcc_attach # attachments saved with body
# set editor = "emacsclient -a emacs -t"
# set editor = "vim"
set mime_type_query_command = "xdg-mime query filetype"
# send settings
set sendmail = "/usr/bin/msmtp"
set sendmail_wait = 0
# Prefer plain text to html but multipart to plain for those only sending that
alternative_order text/calendar application/ics text/plain text/enriched text/html multipart/mixed multipart/related text/plain text/*
# Display Settings
set allow_ansi # allow escape codes for color etc
set sort = threads
set sort_re # thread based on regex below
# look for attachments also in multipart/alternatives
set count_alternatives = yes
# AFAIK we do not have to manually ensure dir existence
set header_cache= "~/.cache/neomutt/hcache/"
# recommended https://github.com/neomutt/neomutt/issues/3259#issuecomment-1043693471
set header_cache_backend = "lmdb"
set header_cache_compress_method = "lz4"
set header_cache_compress_level = 9
################### Compose settings
# allow editing headers while writing mail
set edit_headers
# separate signature from mail
set sig_dashes
# automatically fill in from and subject for replies
set fast_reply
# subject for forwarding
set forward_format = "Fwd: %s"
# default send back to reply-to: header instead of from: header
set reply_to
# default to reply as person e-mail was originally sent to
set reverse_name
# include original msg in reply
set include
# include original msg as quote in fwd
set forward_quote
# forward attachments with mail
set mime_forward = no
# attachments saved with body
set fcc_attach
# we use mimeo in this house
set mime_type_query_command = "mimeo -m"
# send settings
set sendmail = "/usr/bin/msmtp"
set sendmail_wait = 10
################## Display Settings
# allow escape codes for color etc
set allow_ansi
# thread based on the regexes below
set reply_regex = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"
set quote_regex = "^( {0,4}[>|:#%]| {0,4}[A-Za-z0-9]+[>|]+)+"
set sort_aux = last-date-received
#### Thread ordering
set use_threads=reverse
set sort='last-date'
set sort_aux = date
set collapse_all = yes
set uncollapse_new = no
set thread_received = yes
set narrow_tree=no
# set date_format = "%z/%m/%d %I:%M%p"
# set date_format = "%m/%d"
# set index_format = "%4C [%Z] %{%y/%b %d} %-20.20F %s"
set narrow_tree = yes
# sidebar view options
set sidebar_visible = yes
set sidebar_width = 24
# set sidebar_format = "%B%?F? [%F]?%* %?N?%N/?%S"
set sidebar_divider_char = ' ░'
set sidebar_folder_indent = yes
set sidebar_indent_string = ' - '
set sidebar_width = 20
set sidebar_visible = no
set sidebar_next_new_wrap = yes
set sidebar_short_path = yes
set sidebar_component_depth = 0
color sidebar_new color221 color233
set sidebar_divider_char = '│'
set sidebar_next_new_wrap = yes
set sidebar_sort = 'path'
# Shorten mailbox names
set sidebar_short_path = yes
# Delete everything up to the last / character
set sidebar_delim_chars="/"
# Indent folders whose names we've shortened
set sidebar_folder_indent = yes
# Indent with two spaces
# set sidebar_indent_string = ' - '
set sidebar_indent_string=" "
# statusbar view options
set status_chars = " *%A"
# set status_format = "───[ Folder: %f ]───[%r%m messages%?n? (%n new)?%?d? (%d to delete)?%?t? (%t tagged)? ]───%>─%?p?( %p postponed )?───"
# pager view options
set pager_index_lines = 10
set pager_context = 3
set pager_stop # do not go to next msg if at bottom of pager
# do not go to next msg if at bottom of pager
set pager_stop
set menu_scroll = yes
set tilde # show tildes for blank lines
unset markers # no + markers for wrapped stuff
set wrap = 90
# show tildes for blank lines
set tilde
# no + markers if a line goes off-screen
unset markers
set wrap = 100
# hide headers except for those explicitly unignored
ignore *
unignore From To Cc Bcc Date Subject Message-ID
unhdr_order *
unignore From To Cc Bcc Date Subject Message-ID
set query_command = "khard email --parsable --search-in-source-files '%s'"
set nm_query_type = "threads" # Makes notmuch return threads rather than messages
# TODO: Remove stderr ignore when khard fixes its deprecation warnings
# https://github.com/lucc/khard/issues/335
set query_command = "khard email --parsable --search-in-source-files '%s' 2>/dev/null"
# Makes notmuch return threads rather than messages
set nm_query_type = "threads"

73
office/.local/bin/neomutt-filer Executable file
View file

@ -0,0 +1,73 @@
#!/usr/bin/env bash
# A simple utility script for neomutt to use your favorite cli
# file manager to work with files in neomutt.
# Can add attachments to emails or save attachments in a chosen directory.
#
# Use it as `neomutt-filer attach <my-base-dir>`
# or `neomutt-filer saveto <my-base-dir>`
#
# Can be bound to neomutt macros like the following:
#
# macro compose A '<enter-command>source "neomutt-filer attach"|<enter>' "Attach with file manager"
# macro attach S '<enter-command>source "neomutt-filer saveto"|<enter>' "Save attachment to dir"
#
# read more at the following GH issues:
# https://github.com/neomutt/neomutt/issues/1515 -- switch folders with external program
# https://github.com/neomutt/neomutt/issues/1669 -- attach files with fzf
_file_picker() {
if command -v vifm >/dev/null 2>&1; then
vifm --choose-files - "$@"
# yazi & ranger untested
elif command -v yazi >/dev/null 2>&1; then
yazi "$@" --chooser-file -
elif command -v ranger >/dev/null 2>&1; then
ranger --choosefiles - "$@"
elif command -v fzf >/dev/null 2>&1; then
fzf -m --prompt='Choose one/multiple file(s) to attach >' "$@"
fi
}
_dir_picker() {
if command -v vifm >/dev/null 2>&1; then
vifm --choose-dir - --on-choose exit "$@"
# yazi & ranger untested
# elif command -v yazi >/dev/null 2>&1; then
# yazi "$@" --chooser-file -
# elif command -v ranger >/dev/null 2>&1; then
# ranger --choosefiles - "$@"
elif command -v fzf >/dev/null 2>&1; then
find "$@" -type d -print | fzf --prompt='Choose dir >'
fi
}
attachfile() {
_file_picker "$@" |
while IFS=$'\n' read -r attachment; do
printf "push '<attach-file>%s<enter>'\n" "$attachment"
done
}
savetodir() {
_dir_picker "$@" | xargs printf "push '<save-entry>%s<enter>y<enter>'\n"
}
_usage() {
echo """
Usage: neomutt-filer <subcommand> [options...]
Subcommands:
attach Pick files to attach
saveto Pick a directory to save into
"""
}
case "${1:-}" in
attach)
shift
attachfile "$@"
;;
saveto)
shift
savetodir "$@"
;;
-h | --help | *) _usage ;;
esac

View file

@ -2,7 +2,11 @@
# render html as markdown and display in glow, supports syntax highlighting
# requires: html2text, glow or bat
# author: CEUK
fpath=/tmp/mutt.md
fpath=$(mktemp --suffix=-neomutt-render.html)
#shellcheck disable=SC2064 # we want to expand it instantly
trap "rm -f -- ${fpath@Q}" EXIT
perl -0777pe 's/(<code class="sourceCode\s?)(\w+?)(">)(.*?)(<\/code>)/\1\2\3\n```\2\n\4\n```\n\5/gs' "$1" | html2text | sed -re 's/^\s+(```(\w+)?)/\1/gm' -e 's/\x1b\[[6-9;]*m//g' >"$fpath"
@ -13,5 +17,3 @@ elif command -v glow >/dev/null 2>&1; then
else
sed 's/\x1b\[[6-9;]*m//g' <"$fpath"
fi
rm "$fpath" || exit 1