From c2471f212ed2336c691af881e00932c1eb0a1b27 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Wed, 15 Feb 2023 23:27:53 +0100 Subject: Use aerc for mail by default But keep neomutt installed for now, just in case. --- tw/home/files/aerc/accounts.conf | 55 +++++++++++ tw/home/files/aerc/aerc.conf | 149 +++++++++++++++++++++++++++++ tw/home/files/aerc/binds.conf | 159 +++++++++++++++++++++++++++++++ tw/home/files/aerc/filters/colorize.ansi | 134 ++++++++++++++++++++++++++ tw/home/files/aerc/stylesets/catppuccin | 36 +++++++ 5 files changed, 533 insertions(+) create mode 100644 tw/home/files/aerc/accounts.conf create mode 100644 tw/home/files/aerc/aerc.conf create mode 100644 tw/home/files/aerc/binds.conf create mode 100755 tw/home/files/aerc/filters/colorize.ansi create mode 100644 tw/home/files/aerc/stylesets/catppuccin (limited to 'tw/home/files/aerc') diff --git a/tw/home/files/aerc/accounts.conf b/tw/home/files/aerc/accounts.conf new file mode 100644 index 00000000..a29f1453 --- /dev/null +++ b/tw/home/files/aerc/accounts.conf @@ -0,0 +1,55 @@ +[Mythic Beasts] +source = imaps://timo%40twilken.net@oncilla.mythic-beasts.com +outgoing = smtps+plain://timo%40twilken.net@smtp-auth.mythic-beasts.com +source-cred-cmd = pass www/mythic-beasts/email/timo | head -1 +outgoing-cred-cmd = pass www/mythic-beasts/email/timo | head -1 +default = INBOX +from = Timo Wilken +copy-to = Sent +postpone = Drafts +cache-headers = true + +[CERN] +source = imaps+insecure://twilken@imap.cern.ch +outgoing = smtp+login://twilken@smtp.cern.ch +source-cred-cmd = pass cern/sso | head -1 +outgoing-cred-cmd = pass cern/sso | head -1 +default = INBOX +smtp-starttls = yes +from = Timo Wilken +copy-to = Sent +postpone = Drafts +cache-headers = true + +[Gmail] +source = imaps://timo.21.wilken%40gmail.com@imap.gmail.com +outgoing = smtps+login://timo.21.wilken%40gmail.com@smtp.gmail.com +source-cred-cmd = pass www/google/app-passwords/mutt | head -1 +outgoing-cred-cmd = pass www/google/app-passwords/mutt | head -1 +default = INBOX +from = Timo Wilken +copy-to = [Gmail]/Sent Mail +postpone = [Gmail]/Drafts +cache-headers = true + +[Cantab] +source = imaps+xoauth2://tw466%40cantab.ac.uk@outlook.office365.com +outgoing = smtps+xoauth2://tw466%40cantab.ac.uk@smtp-mail.outlook.com +source-cred-cmd = mutt_oauth2.py --encryption-pipe='gpg --encrypt --recipient timo@twilken.net' "$XDG_DATA_HOME/neomutt/cantab.gpg" +outgoing-cred-cmd = mutt_oauth2.py --encryption-pipe='gpg --encrypt --recipient timo@twilken.net' "$XDG_DATA_HOME/neomutt/cantab.gpg" +default = INBOX +from = Timo Wilken +copy-to = Sent Items +postpone = Drafts +cache-headers = true + +[Outlook] +source = imaps+xoauth2://timo_wilken%40live.co.uk@outlook.office365.com +outgoing = smtps+xoauth2://timo_wilken%40live.co.uk@smtp-mail.outlook.com +source-cred-cmd = mutt_oauth2.py --encryption-pipe='gpg --encrypt --recipient timo@twilken.net' "$XDG_DATA_HOME/neomutt/outlook.gpg" +outgoing-cred-cmd = mutt_oauth2.py --encryption-pipe='gpg --encrypt --recipient timo@twilken.net' "$XDG_DATA_HOME/neomutt/outlook.gpg" +default = INBOX +from = Timo Wilken +copy-to = Sent +postpone = Drafts +cache-headers = true diff --git a/tw/home/files/aerc/aerc.conf b/tw/home/files/aerc/aerc.conf new file mode 100644 index 00000000..db83c7c4 --- /dev/null +++ b/tw/home/files/aerc/aerc.conf @@ -0,0 +1,149 @@ +# aerc main configuration + +[general] +#default-save-path= +# Allow world-readable accounts.conf. This is fine as I don't store any +# passwords there, only "pass" commands. +unsafe-accounts-conf=true + +[ui] +# Describes the format for each row in a mailbox view. This field is compatible +# with mutt's printf-like syntax. +index-format=%4C %Z %19D %-17.17n %s + +# See time.Time#Format at https://godoc.org/time#Time.Format +timestamp-format=Mon _2 Jan 2006 15:04 + +# List of space-separated criteria to sort the messages by, see *sort* +# command in *aerc*(1) for reference. Prefixing a criterion with "-r " +# reverses that criterion. +sort=-r date + +threading-enabled=true + +next-message-on-delete=false + +sidebar-width=24 + +styleset-name=catppuccin +pinned-tab-marker='πŸ“Œ' +# Use box-drawing characters for vertical and horizontal borders. +border-char-vertical=β”‚ +border-char-horizontal=─ +# Use UTF-8 symbols to indicate PGP status of messages +icon-unencrypted= +icon-encrypted=πŸ”’ +icon-signed=βœ” +icon-signed-encrypted=βœ”πŸ”’ +icon-unknown=✘ +icon-invalid=⚠ + +# Activates fuzzy search in commands and their arguments: the typed string is +# searched in the command or option in any position, and need not be +# consecutive characters in the command or option. +#fuzzy-complete=false + +[statusline] +render-format=[%a %p] %S %>%T + +# Defines the mode for displaying the status elements. +# Options: text, icon +display-mode=icon + +[viewer] +# Specifies the pager to use when displaying emails. Note that some filters +# may add ANSI codes to add color to rendered emails, so you may want to use a +# pager which supports ANSI codes. +pager='env LESSKEYIN=/dev/null less -iRM' + +# If an email offers several versions (multipart), you can configure which +# mimetype to prefer. For example, this can be used to prefer plaintext over +# html emails. +alternatives=text/plain,text/html + +# Layout of headers when viewing a message. To display multiple headers in the +# same row, separate them with a pipe, e.g. "From|To". Rows will be hidden if +# none of their specified headers are present in the message. +#header-layout=From|To,Cc|Bcc,Date,Subject + +[compose] +# Default header fields to display when composing a message. To display +# multiple headers in the same row, separate them with a pipe, e.g. "To|From". +#header-layout=To|From,Subject + +# Specifies the command to be used to tab-complete email addresses. Any +# occurrence of "%s" in the address-book-cmd will be replaced with what the +# user has typed so far. +# +# The command must output the completions to standard output, one completion +# per line. Each line must be tab-delimited, with an email address occurring as +# the first field. Only the email address field is required. The second field, +# if present, will be treated as the contact name. Additional fields are +# ignored. +# +# This parameter can also be set per account in accounts.conf. +address-book-cmd=khard email --parsable %s + +# Allow to address yourself when replying +reply-to-self=false + +# Warn before sending an email that matches the specified regexp but does not +# have any attachments. Leave empty to disable this feature. +# Uses Go's regexp syntax, documented at https://golang.org/s/re2syntax. The +# "(?im)" flags are set by default (case-insensitive and multi-line). +no-attachment-warning=^[^>]*(attach|Anhang|angehΓ€ngt) + +[filters] +# Filters allow you to pipe an email body through a shell command to render +# certain emails differently, e.g. highlighting them with ANSI escape codes. +# +# The commands are invoked with sh -c. The following folders are appended to +# the system $PATH to allow referencing filters from their name only: +# +# ${XDG_CONFIG_HOME:-~/.config}/aerc/filters +# ${XDG_DATA_HOME:-~/.local/share}/aerc/filters +# $PREFIX/share/aerc/filters +# /usr/share/aerc/filters +# +# The following variables are defined in the filter command environment: +# +# AERC_MIME_TYPE the part MIME type/subtype +# AERC_FILENAME the attachment filename (if any) +# +# The first filter which matches the email's mimetype will be used, so order +# them from most to least specific. +# +# You can also match on non-mimetypes, by prefixing with the header to match +# against (non-case-sensitive) and a comma, e.g. subject,text will match a +# subject which contains "text". Use header,~regex to match against a regex. +text/plain=colorize.ansi +text/calendar=calendar +message/delivery-status=colorize.ansi +message/rfc822=colorize.ansi +#text/html=pandoc -f html -t plain | colorize +#text/html=html | colorize +text/html=lynx -display_charset=UTF-8 -force_html -dump -stdin +#text/*=bat -fP --file-name="$AERC_FILENAME" +#application/x-sh=bat -fP -l sh +#image/*=catimg -w $(tput cols) - +image/*=kitty +kitten icat /dev/stdin +#subject,~Git(hub|lab)=lolcat -f +#from,thatguywhodoesnothardwraphismessages=fmt -w 72 | colorize + +[openers] +# Openers allow you to specify the command to use for the :open action on a +# per-MIME-type basis. +# +# {} is expanded as the temporary filename to be opened. If it is not +# encountered in the command, the temporary filename will be appened to the end +# of the command. +# +# Examples: +# text/html=surf -dfgms +# text/plain=gvim {} +125 +# message/rfc822=thunderbird +application/pdf=zathura + +[triggers] +# Executed when a new email arrives in the selected folder +new-email=exec dunstify -a aerc -i mail-unread "New mail from %n" "%s" diff --git a/tw/home/files/aerc/binds.conf b/tw/home/files/aerc/binds.conf new file mode 100644 index 00000000..28bb5a7f --- /dev/null +++ b/tw/home/files/aerc/binds.conf @@ -0,0 +1,159 @@ +# Binds are of the form = +# To use '=' in a key sequence, substitute it with "Eq": "" +# If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit + = :prev-tab + = :next-tab + = :term +? = :help keys + +[messages] +q = :quit + +j = :next + = :next + = :next 50% + = :next 100% + = :next 100% + +k = :prev + = :prev + = :prev 50% + = :prev 100% + = :prev 100% +g = :select 0 +G = :select -1 +"#" = :select + +J = :next-folder +K = :prev-folder +H = :collapse-folder +L = :expand-folder + +v = :mark -t +V = :mark -T +F = :flag -x Flagged + = :read -t + = :remark + +T = :toggle-threads + + = :view +D = :delete +A = :archive flat +p = :split 25 + +m = :compose + +f = :forward -F +a = :reply -aq +r = :reply -q + +C = :copy +S = :save +s = :move + +c = :cf +$ = :check-mail +! = :term +| = :pipe + +/ = :search +l = :filter +n = :next-result +N = :prev-result + = :clear:unmark -a + +[messages:folder=Drafts] + = :recall + +[messages:account=Mythic Beasts] +d = :move Rubbish +# We can't use both :account= and :folder= at the same time, unfortunately. +[messages:folder=Rubbish] +d = :delete + +[messages:account=CERN] +d = :move Deleted Items +[messages:folder=Deleted Items] +d = :delete + +[messages:account=Gmail] +d = :move [Gmail]/Bin +[messages:folder=[Gmail]/Bin] +d = :delete +[messages:folder=[Gmail]/Drafts] + = :recall + +[messages:account=Cantab] +d = :move Deleted Items +[messages:folder=Deleted Items] +d = :delete + +[messages:account=Outlook] +d = :move Deleted +[messages:folder=Deleted] +d = :delete + +[view] +/ = :toggle-key-passthrough/ +q = :close +O = :open +S = :save +| = :pipe +D = :delete +A = :archive flat + + = :open-link + = :toggle-key-passthrough + +f = :forward -F +a = :reply -aq +r = :reply -q + +H = :toggle-headers + = :prev-part + = :next-part +J = :next +K = :prev + +[view::passthrough] +$noinherit = true +$ex = + = :toggle-key-passthrough + +[compose] +# Keybindings used when the embedded terminal is not selected in the compose view. +$noinherit = true +$ex = + = :prev-field + = :next-field + = :switch-account -p + = :switch-account -n + = :next-field + = :prev-tab + = :next-tab + +[compose::editor] +# Keybindings used when the embedded terminal is selected in the compose view. +$noinherit = true +$ex = + = :prev-field + = :next-field + = :prev-tab + = :next-tab + +[compose::review] +# Keybindings used when reviewing a message to be sent +y = :send +n = :abort +p = :postpone +q = :choose -o d discard abort -o p postpone postpone +e = :edit +a = :attach +d = :detach + +[terminal] +$noinherit = true +$ex = + = :prev-tab + = :next-tab diff --git a/tw/home/files/aerc/filters/colorize.ansi b/tw/home/files/aerc/filters/colorize.ansi new file mode 100755 index 00000000..c21fd804 --- /dev/null +++ b/tw/home/files/aerc/filters/colorize.ansi @@ -0,0 +1,134 @@ +#!/usr/bin/env -S awk -f +# Copyright (c) 2022 Robin Jarry +# Adapted for standard ANSI colors (for catppuccin theme) by Timo Wilken. + +BEGIN { + url = "\033[32m" # green + header = "\033[35m" # pink + signature = "\033[38m" # Surface 2 + diff_meta = "\033[1;37m" # bold white + diff_chunk = "\033[36m" # teal + diff_add = "\033[32m" # green + diff_del = "\033[31m" # red + quote_1 = "\033[38;5;15m" # Subtext 0 + quote_2 = "\033[37m" # Subtext 1 + quote_3 = "\033[38m" # Surface 2 + quote_4 = "\033[30m" # Surface 1 + quote_x = "\033[30m" # Surface 1 + bold = "\033[1m" + reset = "\033[0m" + # state + in_diff = 0 + in_signature = 0 + in_headers = 0 + in_body = 0 + # patterns + header_pattern = @/^[A-Z][[:alnum:]-]+:/ + url_pattern = @/[a-z]{2,6}:\/\/[[:graph:]]+|(mailto:)?[[:alnum:]_\+\.~\/-]*[[:alnum:]_]@[[:lower:]][[:alnum:]\.-]*[[:lower:]]/ + meta_pattern = @/^(diff --git|(new|deleted) file|similarity index|(rename|copy) (to|from)|index|---|\+\+\+) / +} +function color_quote(line) { + level = 0 + quotes = "" + while (line ~ /^>/) { + level += 1 + quotes = quotes ">" + line = substr(line, 2) + while (line ~ /^ /) { + quotes = quotes " " + line = substr(line, 2) + } + } + if (level == 1) { + color = quote_1 + } else if (level == 2) { + color = quote_2 + } else if (level == 3) { + color = quote_3 + } else if (level == 4) { + color = quote_4 + } else { + color = quote_x + } + if (line ~ meta_pattern) { + return color quotes bold line reset + } else if (line ~ /^\+/) { + return color quotes diff_add line reset + } else if (line ~ /^-/) { + return color quotes diff_del line reset + } + gsub(url_pattern, url "&" color, line) + return color quotes line reset +} +{ + # Strip carriage returns from line + sub(/\r$/, "") + + if (in_diff) { + if ($0 ~ /^-- ?$/) { + in_diff = 0 + in_signature = 1 + $0 = signature $0 reset + } else if ($0 ~ /^@@ /) { + gsub(/^@@[^@]+@@/, diff_chunk "&" reset) + } else if ($0 ~ meta_pattern) { + $0 = diff_meta $0 reset + } else if ($0 ~ /^\+/) { + $0 = diff_add $0 reset + } else if ($0 ~ /^-/) { + $0 = diff_del $0 reset + } else if ($0 !~ /^ / && $0 !~ /^$/) { + in_diff = 0 + in_body = 1 + if ($0 ~ /^>/) { + $0 = color_quote($0) + } else { + gsub(url_pattern, url "&" reset) + } + } + } else if (in_signature) { + gsub(url_pattern, url "&" signature) + $0 = signature $0 reset + } else if (in_headers) { + if ($0 ~ /^$/) { + in_headers = 0 + in_body = 1 + } else { + sub(header_pattern, header "&" reset) + gsub(url_pattern, url "&" reset) + } + } else if (in_body) { + if ($0 ~ /^>/) { + $0 = color_quote($0) + } else if ($0 ~ /^diff --git /) { + in_body = 0 + in_diff = 1 + $0 = diff_meta $0 reset + } else if ($0 ~ /^-- ?$/) { + in_body = 0 + in_signature = 1 + $0 = signature $0 reset + } else { + gsub(url_pattern, url "&" reset) + } + } else if ($0 ~ /^diff --git /) { + in_diff = 1 + $0 = diff_meta $0 reset + } else if ($0 ~ /^-- ?$/) { + in_signature = 1 + $0 = signature $0 reset + } else if ($0 ~ header_pattern) { + in_headers = 1 + sub(header_pattern, header "&" reset) + gsub(url_pattern, url "&" reset) + } else { + in_body = 1 + if ($0 ~ /^>/) { + $0 = color_quote($0) + } else { + gsub(url_pattern, url "&" reset) + } + } + + print +} diff --git a/tw/home/files/aerc/stylesets/catppuccin b/tw/home/files/aerc/stylesets/catppuccin new file mode 100644 index 00000000..ebc7bfba --- /dev/null +++ b/tw/home/files/aerc/stylesets/catppuccin @@ -0,0 +1,36 @@ +*.selected.reverse = false +*.selected.bg = #585b70 +error.fg = #eba0ac +warning.fg = #fab387 +success.fg = #a6e3a1 +title.fg = default +title.bold = true +header.fg = #f5c2e7 +header.bold = true + +msglist_read.default = true +msglist_unread.fg = #a6e3a1 +msglist_flagged.fg = #eba0ac +msglist_flagged.bold = true +msglist_deleted.fg = #f38ba8 +msglist_marked.fg = #f5e0dc + +dirlist_default.bg = #11111b +dirlist_unread.fg = #a6e3a1 +dirlist_recent.fg = #89dceb + +tab.bg = #313244 +tab.selected.bold = true +stack.bg = #6c7086 +spinner.fg = #fab387 + +statusline_default.bg = #313244 +statusline_error.fg = #eba0ac +statusline_success.fg = #a6e3a1 + +completion_default.bg = #11111b +# The "gutter" contains the scrollbar of the completion popup. +completion_gutter.bg = #11111b +# The "pill" is the part of the scrollbar that indicates progress +# through the list. +completion_pill.bg = #585b70 -- cgit v1.2.3