diff --git a/config/neomutt/extract-reply.sh b/config/neomutt/extract-reply.sh new file mode 100755 index 0000000..d2dd9bc --- /dev/null +++ b/config/neomutt/extract-reply.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +set -euo pipefail + +text="$(cat)" + +# Extract only the text/html part of the multipart email +# TODO parse actual encoding instead of defaulting to iso-8859-1 +mailto="$(printf "%s" "$text" \ + | awk ' + boundary { + if ($0 ~ boundary) { + boundary = ""; + next + } + print $0 + } + + /Content-Type: text\/html;/ { + boundary=line + } + + { + line=$0 + }' \ + | qprint -d \ + | iconv -f iso-8859-1 -t utf-8 \ + | grep -Eo ' "$datadir/info.rc" diff --git a/config/neomutt/keys.rc b/config/neomutt/keys.rc index ee3f13a..a2ce82f 100644 --- a/config/neomutt/keys.rc +++ b/config/neomutt/keys.rc @@ -55,6 +55,13 @@ bind pager gh display-toggle-weed bind pager ge extract-keys macro pager gu " urlscan " +# Answer emails with a reply address in the body +# https://unix.stackexchange.com/a/586010/248368 +macro pager gr " ~/.config/neomutt/extract-reply.sh \ + source ~/.local/share/neomutt/info.rc \ + " +# Use a hook to reset sender and subject just after creating the reply +send-hook . 'unmy_hdr To: Subject:' ########## # ATTACH #