2

How can one make mutt display ONLY the last instance of a particular header.

In many cases, such as g.e. UCE messages or phishing messages, the last (or oldest) of several "Received:" lines is the one of interest to obtain an idea of the origin of the mail. Is there a way of of making mutt display only the last instance of the "Received:" header?

3

You could use display_filter:

3.54 display_filter

Type: path
Default: (empty)

When set, specifies a command used to filter messages. When a message is viewed it is passed as standard input to $display_filter, and the filtered message is read from the standard output.

This requires some other command that can read a message from stdin and filter the "Received" headers accordingly. eg.

$ cat last-rec.sed
0,/^$/{ # only process headers
    :hdr
    /^Received:/{
        h # overwrite any previous Received line
        :fold
        # read next line without printing current
        N
        s/^.*\n//
        /^[[:space:]]/{
            H # append to current Received line
            b fold
        }
        b hdr
    }
    /^$/{
        # show final received line
        x
        p
        # and the empty line
        x
    }
}

(This has the side-effect of moving the remaining Received: line below all the other headers.)

Then set it up in muttrc:

set display_filter="sed -f /path/to/last-rec.sed"
| improve this answer | |
  • JigglyNaga's suggestion is working flawlessly for me. Thanks. – elie Aug 25 '16 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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