From 8b3920deb518d2f104fd893a8ccb440a968dffc5 Mon Sep 17 00:00:00 2001 From: lara Date: Sat, 1 Oct 2022 12:35:35 +0200 Subject: [PATCH] [neomutt] Add keybind to reply based on mailto: link in the body --- config/neomutt/extract-reply.sh | 42 +++++++++++++++++++++++++++++++++ config/neomutt/keys.rc | 7 ++++++ 2 files changed, 49 insertions(+) create mode 100755 config/neomutt/extract-reply.sh 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 #