Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In my .muttrc I have attribution set to emulate Outlook-style message quoting like this:

set attribution="\n\n-----Original Message-----\nFrom: %f\nSent: %d\n%t\nSubject: %s\n"

However, the %t expando evaluates to "To Persons_Name" with no colon after the "To" so I'd like to run it through a shell command to add the colon. I can use backticks to run a shell command but I can't figure out how to get the value of the %t expando in the shell command. I've tried this but it doesn't work:

set attribution="\n\n-----Original Message-----\nFrom: %f\nSent: %d\n`echo %t | sed s/^To/To:/`\nSubject: %s\n"
share|improve this question

1 Answer 1

up vote 3 down vote accepted

The shell commands are executed when the config setting is read, not every time you reply. You can see that by entering

 set attribution="Date: `date`"

It never changes. And of course, expandos aren't expanded at that moment.

There is way: if you end the string with a |, mutt assumes it is a command and just executes it and uses its output (the documentation says it pipes the arguments through the first word, but that's a lie).

The problem is, there isn't any unix command (that I know of) which applies a regex to its arguments and outputs the result. sed, for instance, only works on files or stdin.

You have to create that command yourself. In Perl, it would be something like that:


my $regexp = shift;
my @out;
for (@ARGV) {
  eval $regexp;
  push @out, $_;

print join " ", @out;

Let's say you put this in your path and name it r.pl (remember to chmod-x it), then you can set your attribution this way:

set attribution="r.pl 's/^To /To: /m' 'From: %n\n%t\netc...\n'|"

Take a look into man perlre to find out why you need to end the regexp with /m.


share|improve this answer
This is great. I got it into an (ugly) one-liner like this: set attribution="perl -e \'$_=shift;s/^To /To: /m;print;\' \"\n\n-----Original Message-----\nFrom: %f\nSent: %d\n%t\nSubject: %s\"|". Only problem is it seems to eat any trailing whitespace so I can't get a blank line before the message body, but I can live with that. –  Ben Williams Jan 6 '12 at 16:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.