I have following value set for index_format
in mutt:
"%Z %{%Y %b %e %H:%M} %?X?(%X)& ? %-22.22F %.100s %> %5c "
which displays date in the format as
2013 Dec 5
I was wondering whether it is possible to have different date formats depending on how old the email is. By that I mean:
for less than 7 days: today, yesterday, tuesday, monday
this year: Dec 5
older than this year: 2013 Dec 5
I think I have seen this functionality in Thunderbird. Would be nice to have it in mutt
Best Answer
If you are using the "development" version of mutt (v1.5+) - and you absolutely should - there is the possibility to use an external filter as described in the manual.
First you need a script that can output different things according to the age of a message. Here is an example in Python:
Save this as
mutt-fmt-date
somewhere on your PATH.Two things are important here:
{}
which is replaced with the return value ofage_fmt()
by Python.%
so that Mutt will interpret it.Then you can use it in your
.muttrc
as follows:Mutt will then
%[%s]
according to the rules for format strings.mutt-fmt-date
with the result of 1. as argument (because of the|
at the end).%
at the end).Caveat: the script will be executed for every message that is to be about be displayed. The resulting delay can be quite noticable when scrolling through a mailbox.
Here is a version in C that performs somewhat adequately:
This goes together with the muttrc line: