#!/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 -eu 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 my_filter=\"$editor\"" echo -n "push '" echo -n "set editor=\"\$my_filter\"" echo -n "" echo -n "set editor=\"\$my_editor\"" echo -n "unset my_filter" echo -n "unset my_editor" echo "'"