On Fri, Jan 07, 2011 at 05:29:32AM -0600, David Champion wrote:
Aha, finally I have discovered a use for mutt's % expando.
You can optimize this one step further.
set index_format="./format_date.sh '%[%Y%m%d]' '%<%Y%m%d>' |"
#!/bin/sh
if [ $1 -eq $2 ]; then
echo "%4C %Z %{ %H:%M} %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%"
else
echo "%4C %Z %{%d.%m.%y} %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%"
fi
A single exec per message now; that's as good as it gets without
patching mutt.
Outstanding! I didn't notice a slowdown from the extra exec, but saving
cycles isn't a bad thing if you don't have to sacrifice clarity.
I went a little bit crazy with this, and now have different formats for
less than a day old, more than a day but less than a week old, more than
a week but less than 30 days, and more than 30 days. I've attached it.
Here's a (censored) view of my index right before I started this
message:
102 12/16/10 xx...@xx.xx ( 8) x - xxx xx.
103 + Dec 27 xxx xxx xx ( 80) xx xxx xx
104 + Jan 03 xx xxx ( 98) xx: xx xxx
105 T Jan 04 xx ( 104) xxx xxx xxx
106 L Jan 07 x ( 54) xx: xx xx: xxx x,
xxx xx.
107 Jan 07 x ( 92) xx xx x
1/4 xxx
108 + Jan 12 xxx x x ( 82) xx xx xxx xx
109 + Jan 13 x, x( 23) xx: !
110 + Mon 9pm x xxx ( 20) xx: x4x xxx xx (xxx: x
/ )
111 T Tue 2pm xx ( 153) xxx xxx x
112 T Wed 11am xxx ( 157) xx
113 Wed 3pm x xx( 266) xxx xxx, xx
x_xx__xx
114 T 8:59pm x ( 21) x xxx xxx xxx xx x
xxx
115 + 9:11pm xx xxx ( 50) xx:
The script relies on Unix epoch seconds for the calculation, so the break
point is 24 hours ago, 168 hours ago, etc, not day boundaries, but
that's what I want. I think day boundaries would be possible with some
work on the msg_age calculation, maybe "$(( ($now/86400) - ($msg_date/86400) ))"?
Ed
#!/bin/bash
# format_date
#
# In .muttrc:
# set index_format="/path/to/format_date '%[%s]' '%<%s>' |"
#
#
http://groups.google.com/group/de.comm.software.mailreader.misc/browse_thread/thread/ab966bddc0b424
46/421549103438b830?q=#421549103438b830
# via Andreas Kneib
# mutt-users Message-ID: <20110105233817.ga23...@andreas.kneib.biz>
# Improvements by
# David Champion
# Ed Blackman
msg_date="$1" # datetime of message in local timezone
in epoch seconds
now="$2"# current time in local timezone in
epoch seconds
msg_age="$(( ($now - $msg_date) / 86400 ))" # age of message in
integer days
if [ $msg_age -ge 30 ]; then
format="%[%m/%d/%y]" # '01/20/11'
elif [ $msg_age -ge 7 ]; then
format="%8[%b %d]"# ' Jan 20'
elif [ $msg_age -ge 1 ]; then
format="%8[%a %-I%P]" # ' Thu 6pm'
else
format="%[ %_I:%M%P]" # ' 6:41pm'
fi
echo "%4C %Z $format %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%"
signature.txt
Description: Digital signature