Colorizing messages in mutt (stab 2)

mutt-score-colors-example-scaledThis image shows the different scores (“[1000]” scores red background, “[800]” magenta text, etc.). At work I use a slightly different set.

I think I got it, at least in the index (for some reason it doesn’t work from the pager, maybe it’s the source command there)! I’m able to tag a message with a score, and have that score translate into a different color. Here’s the relevant part of my .muttrc:

# Star scoring 
source ~/.mutt/stars
bind index,pager s noop # I use 'y' to archive messages, no need for 's' to be bound to <save-message>.  This frees it up so I can use it below.

set my_red_star = 1000
set my_magenta_question = 800
set my_yellow_bang = 600
set my_green_star = 400
set my_green_check = 200
set my_blue_info = 100
set my_del_star = 0

macro index,pager sr "<pipe-entry>~/bin/stars $my_red_star<enter><enter-command>source ~/.muttrc<enter>" "Mark the current message with RED"
macro index,pager sm "<pipe-entry>~/bin/stars $my_magenta_question<enter><enter-command>source ~/.muttrc<enter>" "Mark the current message with MAGENTA"
macro index,pager sy "<pipe-entry>~/bin/stars $my_yellow_bang<enter><enter-command>source ~/.muttrc<enter>" "Mark the current message with YELLOW"
macro index,pager sc "<pipe-entry>~/bin/stars $my_green_check<enter><enter-command>source ~/.muttrc<enter>" "Mark the current message with GREEN"
macro index,pager si "<pipe-entry>~/bin/stars $my_blue_info<enter><enter-command>source ~/.muttrc<enter>" "Mark the current message with BLUE"
macro index,pager sg "<pipe-entry>~/bin/stars $my_green_check<enter><enter-command>source ~/.muttrc<enter>" "Mark the current message with GREEN"
macro index,pager sd "<pipe-entry>~/bin/stars $my_del_star<enter><pipe-entry>~/bin/del_stars<enter><enter-command>source ~/.muttrc<enter><sync-mailbox>" "Remove color marking from the current message"

color index default brightred '~n 1000-1100'  # Mark the message with red!
color index magenta default '~n 800-999'  # Mark the message with magenta!
color index black brightyellow '~n 600-799'  # Mark the message with yellow!
color index default green '~n 400-599'  # Mark the message with green!
color index green default '~n 200-399'  # Mark the message with green (check)!
color index brightblue default '~n 100-199'  # Mark the message with blue!

Not much different than I had before. The problems I had were the .mutt/stars, bin/stars, bin/del_stars. It mostly worked once I got it set up, except for messages that had special regular-expression reserved characters in the message ID. Here’s the bin/stars file I have:

#!/bin/bash
SCORE=$1                                
msgid=$(sed '/^Message-I[Dd]:[[:space:]]*/!d; s///; s/[<>]//g; s/[][$|]/\\&/g; q')
echo "score \"~i '$msgid'\" $SCORE" >> ~/.mutt/stars 

The key was the single quotes around the actual message ID. And the del_stars file:

#!/bin/bash

msgid=$(grep -m 1 '^Message-I[Dd]' | awk '{print $2}' | sed 's/[<>]//g; s/[^^]/[&]/g; s/\^/\\^/g')
sed -i "/$msgid/d" ~/.mutt/stars

After some further testing, it still doesn’t work. I have one company that sends me a bill summary, and the Message-Id has square-brackets around an RFC1918 address. Rather than fight with mutt trying to get it to read and score the message properly, I just added the company’s bill email address to my .mutt/stars file, with the following line:

score "~f CompanyEmail@company.com" 600

Also, to get the del_star script to work most times I have to close mutt completely before the score is removed. But otherwise it works!

Timbuk2 Commute Laptop Messenger Bag

Originally submitted at Timbuk2

A Timbuk2 laptop classic. More pockets, waterproof flap and is TSA compliant.


Decent bag for the price

By Trey the Nerd from Smyrna, GA on 3/31/2014

 

4out of 5

Pros: High Quality, Comfortable , Attractive, Good Strap Length, Lightweight , Roomy , Durable 

Cons: Color Choice, Too big

Best Uses: School, Commuting, Extended trips , Day Trips, Airplane travel , Office, Computer

Describe Yourself: Comfort-Oriented, Modern, Practical, Classic, Career

Was this a gift?: No

The quality and workmanship of this bag are stellar, and I expect nothing less from Timbuk2. I will use this as my daily carry laptop bag for the foreseeable future. The TSA compliant features are a little weird, but I’m getting used to them. I honestly haven’t used the rest of the bag except for carrying pens, documents, and my checkbook. Same old Timbuk2 ballistic fabric, same high quality, and I expect the same durability as I got from my still-serviceable fifteen year old Timbuk2 bag. I was about to say something about having a nice extended warranty, but none of the Timbuk2 bags I’ve had (this is my third), have even come close to failing.

Now to the (relatively minor, but still worth -1 star) cons. This bag is TOO BIG. I call into question the idea that a bag designed for a 15″ laptop would fit a 13″ Retina MacBook Pro. I like my laptop to feel nice and snug in my bag, and this is IMPOSSIBLE. I swore I got the smallest they offered, and it’s still too big. I refuse to lug around a laptop larger than 13″ just so it will fit in my bag. My old 11″ ThinkPad fits just fine in my old custom Timbuk2 laptop messenger. If Timbuk2 offered a smaller size for the TSA-complient commute laptop messenger, I would have gladly got it instead. This is my main complaint with this bag, so negative 0.75 stars for it.

Also, the color choices leave me wanting. My last bag was Red Devil on the side panels, and Safety Cone center panels to match my school colors. I tried to do the same thing with with my professional team’s colors, black and gold. The black was easy, but the gold I couldn’t really find in the color/pattern swatch. Barley was the closest I could come, but I’m not entirely happy with it. I bet my brother will make fun of me for it. We’ll see. Also, the color pattern I chose does not go all the way around the bag like my other Timbuk2 bags. The main messenger flap has the color, but I don’t usually access the bag using that. The TSA compartment is completely black. These color issues only warrant a negative 0.25, for a total of -1 stars.

(legalese)

The above is the result of my review which I left on Timbuk2’s website (or the website of their review software provider). To be honest, the bag is great. But they only offer it in one size, and that’s what I complained about. Since it was custom, I had already agreed that I couldn’t return it under any circumstances. That’s a lame stipulation, but I digress.