X-Git-Url: https://git.madduck.net/etc/neomutt.git/blobdiff_plain/a6ac44586209b9b0be5add1bef270451f3dcb677..4d1afcd5cc3e282554877a10d6be81931ef0cc03:/.config/neomutt/batch-subject-editor?ds=sidebyside diff --git a/.config/neomutt/batch-subject-editor b/.config/neomutt/batch-subject-editor new file mode 100755 index 0000000..0649ac5 --- /dev/null +++ b/.config/neomutt/batch-subject-editor @@ -0,0 +1,32 @@ +#!/bin/sh +# +# batch-subject-editor - helper script to change subject lines with mutt +# +# Based on an idea by David Champion +# +# Copyright © 2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +set -eu + +if [ -z "${__RLWRAPPED:-}" ] && [ -x $(command -v rlwrap) ]; then + __RLWRAPPED=true exec rlwrap "$0" "$@" +fi + +printf 'Enter new subject: ' >/dev/tty +read subj &2 + exit 1 +fi + +SED_DELIM=, +subj=$(echo "$subj" | sed -re "s${SED_DELIM}\\\&g") + +RE_REPLY='((re|aw|antwort)([[(]?[[:digit:]]+[)]]?)?):[[:space:]]*' +RE_SUBJ_PREFIX="^Subject:[[:space:]]*(${RE_REPLY})*" +RE_SUBJ='.*' +EDITOR="sed -i -re \"s${SED_DELIM}(${RE_SUBJ_PREFIX})${RE_SUBJ}${SED_DELIM}\\\1$subj${SED_DELIM}i\"" + +printf "set editor='${EDITOR} %s'"