On Fri, Mar 11, 2011 at 12:38:03PM -0600, Will Fiveash wrote: > On Thu, Mar 10, 2011 at 09:40:17PM -0400, Monte Stevens wrote: > > On Thu, Mar 10, 2011 at 07:11:19PM -0600, Will Fiveash wrote: > > > > > > I'm talking about when I create mail for a particular recipient I want > > > the Subject: set. Like this: > > > > > > $ mutt expe...@foo.com > > > > > > and when mutt launched my editor (vim) I would see in the message > > > template I'm editing: > > > > > > From: Will Fiveash <will.five...@oracle.com> > > > To: expe...@foo.com > > > Cc: > > > Bcc: > > > Subject: Expense Report # > > > Reply-To: > > > > > > OK, if you're calling mutt from a shell, you can replace 'mutt' with > > 'mutt.sh', where mutt.sh contains something like: > > > > case "$1" in > > expe...@foo.com) > > /usr/bin/mutt -s "Expense Report # " "$1" > > ;; > > mark.h...@oracle.com) > > /usr/bin/mutt -s "Nice tie" "$1" > > ;; > > esac > > I thought about that but it's not a general enough solution because I > sometime create a new e-mail via a running mutt session (using the 'm' > command).
OK, try the below. I tested it once on expe...@foo.com and it did what I expected it to. (I also adjusted a bit after testing so I hope it still works.) set editor=new-mutt-message.sh contents of new-mutt-message.sh... #!/bin/bash FILE="$1" DIR=$(echo "$1" | grep -o '.*\/') TMP=$(echo "$1" | grep -o '[^\/]*$') cd "$DIR" csplit -qf "$TMP.parts" "$TMP" '/^$/' RECIP=$(cat $TMP.parts00 | grep -im 1 '^To: ' | sed 's/To: \(.*\)/\1/') case "$RECIP" in expe...@foo.com) sed -i 's/^Subject: .*/Subject: Expense Report # /' "$TMP" ;; mark.h...@oracle.com) sed -i 's/^Subject: .*/Subject: Did you bring a lunch?/' "$TMP" ;; esac rm $TMP.parts* $EDITOR $TMP