diff --git a/office/.config/neomutt/account b/office/.config/neomutt/account index 6714331..9abd8b7 100644 --- a/office/.config/neomutt/account +++ b/office/.config/neomutt/account @@ -1,15 +1,15 @@ # Account settings # local maildir settings -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" \ +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" diff --git a/office/.config/neomutt/colors b/office/.config/neomutt/colors index bd7d123..513de51 100644 --- a/office/.config/neomutt/colors +++ b/office/.config/neomutt/colors @@ -5,6 +5,36 @@ 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 ` @@ -26,20 +56,15 @@ 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 "~A" -color index_author magenta default "~A" -color index_number blue default "~A" -color index_subject cyan default "~A" +color index yellow default '.*' +color index_author red default '.*' +color index_number blue default +color index_subject cyan default '.*' -# 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" +# For new mail: +color index brightyellow brightblack "~N" +color index_author brightred brightblack "~N" +color index_subject brightcyan black "~N" color progress black cyan # Nerd icons idea based on https://github.com/sheoak/neomutt-powerline-nerdfonts/ @@ -48,13 +73,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 = '%B%%* %%S' +set sidebar_format = '%D%?Z? [%Z]?%* %?S?%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' " ๏ฃก" @@ -101,7 +126,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 black cyan # selection indicator +color indicator default color8 # selection indicator color index_date color8 default # date is always the same colour color index_label color6 default # label is always the same colour @@ -114,6 +139,7 @@ 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 ----------------------------------------------------------------- diff --git a/office/.config/neomutt/mailcap b/office/.config/neomutt/mailcap index 1f634ff..384dcce 100644 --- a/office/.config/neomutt/mailcap +++ b/office/.config/neomutt/mailcap @@ -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; neomutt-renderhtml %s; nametemplate=%s.html; copiousoutput; +text/html; render-prettyhtml %s; nametemplate=%s.html; copiousoutput; text/plain; $EDITOR %s ; # show calendar invites diff --git a/office/.config/neomutt/maps b/office/.config/neomutt/maps index d46c4d2..a3e79a6 100644 --- a/office/.config/neomutt/maps +++ b/office/.config/neomutt/maps @@ -74,10 +74,6 @@ 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 'source "neomutt-filer attach"|' "Attach with file manager" -macro attach s 'source "neomutt-filer saveto"|' "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 diff --git a/office/.config/neomutt/neomuttrc b/office/.config/neomutt/neomuttrc index 84fcf1c..3932ebf 100644 --- a/office/.config/neomutt/neomuttrc +++ b/office/.config/neomutt/neomuttrc @@ -3,3 +3,4 @@ source settings source maps source account + diff --git a/office/.config/neomutt/settings b/office/.config/neomutt/settings index 3f3636c..6e71428 100644 --- a/office/.config/neomutt/settings +++ b/office/.config/neomutt/settings @@ -1,126 +1,96 @@ + set mail_check = 60 set mail_check_stats -# 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 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 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 + # 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 auto_view application/ics auto_view text/calendar auto_view text/plain auto_view text/html -# 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/* - -# 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 +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" -# 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 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 = 10 +set sendmail_wait = 0 -################## Display Settings -# allow escape codes for color etc -set allow_ansi -# thread based on the regexes below +# Display Settings +set allow_ansi # allow escape codes for color etc +set sort = threads +set sort_re # thread based on regex 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 = 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" # sidebar view options -set sidebar_width = 20 -set sidebar_visible = no -set sidebar_component_depth = 0 -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_visible = yes +set sidebar_width = 24 +# set sidebar_format = "%B%?F? [%F]?%* %?N?%N/?%S" +set sidebar_divider_char = ' โ–‘' set sidebar_folder_indent = yes -# Indent with two spaces -# set sidebar_indent_string = ' - ' -set sidebar_indent_string=" " - +set sidebar_indent_string = ' - ' +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 # 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 -# do not go to next msg if at bottom of pager -set pager_stop +set pager_stop # do not go to next msg if at bottom of pager set menu_scroll = yes -# show tildes for blank lines -set tilde -# no + markers if a line goes off-screen -unset markers -set wrap = 100 +set tilde # show tildes for blank lines +unset markers # no + markers for wrapped stuff +set wrap = 90 # 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 -# 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" +set query_command = "khard email --parsable --search-in-source-files '%s'" +set nm_query_type = "threads" # Makes notmuch return threads rather than messages diff --git a/office/.local/bin/neomutt-filer b/office/.local/bin/neomutt-filer deleted file mode 100755 index 02f6105..0000000 --- a/office/.local/bin/neomutt-filer +++ /dev/null @@ -1,73 +0,0 @@ -#!/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 ` -# or `neomutt-filer saveto ` -# -# Can be bound to neomutt macros like the following: -# -# macro compose A 'source "neomutt-filer attach"|' "Attach with file manager" -# macro attach S 'source "neomutt-filer saveto"|' "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 '%s'\n" "$attachment" - done -} - -savetodir() { - _dir_picker "$@" | xargs printf "push '%sy'\n" -} - -_usage() { - echo """ -Usage: neomutt-filer [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 diff --git a/office/.local/bin/neomutt-renderhtml b/office/.local/bin/render-prettyhtml similarity index 79% rename from office/.local/bin/neomutt-renderhtml rename to office/.local/bin/render-prettyhtml index 9d4a7a0..d6037e2 100755 --- a/office/.local/bin/neomutt-renderhtml +++ b/office/.local/bin/render-prettyhtml @@ -2,11 +2,7 @@ # render html as markdown and display in glow, supports syntax highlighting # requires: html2text, glow or bat # author: CEUK - -fpath=$(mktemp --suffix=-neomutt-render.html) - -#shellcheck disable=SC2064 # we want to expand it instantly -trap "rm -f -- ${fpath@Q}" EXIT +fpath=/tmp/mutt.md perl -0777pe 's/()(.*?)(<\/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" @@ -17,3 +13,5 @@ elif command -v glow >/dev/null 2>&1; then else sed 's/\x1b\[[6-9;]*m//g' <"$fpath" fi + +rm "$fpath" || exit 1