From: martin f. krafft Date: Tue, 16 Sep 2008 13:46:45 +0000 (+0100) Subject: add more flexible header manipulation X-Git-Url: https://git.madduck.net/etc/mutt.git/commitdiff_plain/616f061f77605ce342e3068e5aacda3dffa24710?ds=inline add more flexible header manipulation --- diff --git a/.mutt/append-header b/.mutt/append-header new file mode 120000 index 0000000..5cc745f --- /dev/null +++ b/.mutt/append-header @@ -0,0 +1 @@ +edit-header \ No newline at end of file diff --git a/.mutt/edit-header b/.mutt/edit-header new file mode 100755 index 0000000..3a3a96a --- /dev/null +++ b/.mutt/edit-header @@ -0,0 +1,67 @@ +#!/bin/sh +# +# edit-header - helper script to append/replace/remove headers 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 -euvx + +if [ ! -x "$(command -v formail)" ]; then + echo E: formail not installed. >&2 + exit 1 +fi + +header="${1:-}" +if [ -z "$header" ]; then + echo "E: no header specified" >&2 + exit 1 +fi + +get_header_contents() +{ + local contents + printf "Enter ${1:-header} contents: " >/dev/tty + read contents &2 + exit 1 + ;; + +esac + +echo "set my_editor=\"\$editor\'" +echo "set editor=\"$editor\"" +echo "push " +# we need to push this so it happens after the editing +echo "push :set editor=\"\$my_editor\"" diff --git a/.mutt/filter-proxy b/.mutt/filter-proxy new file mode 100755 index 0000000..bd54b44 --- /dev/null +++ b/.mutt/filter-proxy @@ -0,0 +1,31 @@ +#!/bin/sh +# +# filter-proxy - enable filters to work on real files (using tmpfiles) +# +# Copyright © 2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +set -euvx + +cmd= +file= +while [ -n "${1:-}" ]; do + if [ -z "${2:-}" ]; then + file="$1" + else + case "$1" in + *' '*) cmd="$cmd '$1'";; + *) cmd="$cmd $1";; + esac + fi + shift +done + +TMPFILE="$(tempfile -p proxy)" +trap "rm -f $TMPFILE" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 + +eval $cmd <"$file" >$TMPFILE +cat $TMPFILE >"$file" + +rm -f $TMPFILE +trap - 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 diff --git a/.mutt/get-timestamp b/.mutt/get-timestamp new file mode 100755 index 0000000..4a1c524 --- /dev/null +++ b/.mutt/get-timestamp @@ -0,0 +1,28 @@ +#!/bin/sh +# +# get-timestamp - helper script to obtain a timestamp from the user +# +# Copyright © 2008 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +set -eu + +printf 'When should I tickle you about this message? ' >/dev/tty +read timespec &2 + exit 1 + ;; + *) date="now + $timespec days 00:00";; +esac + +exec date +'%s (%c)' -d "$date" diff --git a/.mutt/remove-header b/.mutt/remove-header new file mode 120000 index 0000000..5cc745f --- /dev/null +++ b/.mutt/remove-header @@ -0,0 +1 @@ +edit-header \ No newline at end of file diff --git a/.mutt/replace-header b/.mutt/replace-header new file mode 120000 index 0000000..5cc745f --- /dev/null +++ b/.mutt/replace-header @@ -0,0 +1 @@ +edit-header \ No newline at end of file diff --git a/.mutt/supersede-header b/.mutt/supersede-header new file mode 120000 index 0000000..5cc745f --- /dev/null +++ b/.mutt/supersede-header @@ -0,0 +1 @@ +edit-header \ No newline at end of file