~adeodato/ blog/ entries/ 2008/ 03/ 23/ Coloring diffs when reading mail in Mutt

Coloring diffs when reading mail in Mutt

This is fairly obvious in theory, but it’s the kind of thing you don’t always think about: when receiving patches via e-mail, it’s possible to have Mutt directly color them as vim or colordiff(1) does. I have this:

  % grep rc_diff ~/.muttrc
  macro   index   \e,sd   ":source ~/.mutt/rc_diff\n" "source ~/.mutt/rc_diff"
  macro   pager   \e,sd   ":source ~/.mutt/rc_diff\n" "source ~/.mutt/rc_diff"

  % cat ~/.mutt/rc_diff
  color body brightblue default   '^\+.*'
  color body brightred default    '^-.*'
  color body brightgreen default  '^(---|\+\+\+) .*'
  color body brightyellow default '^@@ .*'

Update: In case there was some confusion, the rc_diff snippet above is meant to be sourced only when there’s a mail with a patch, otherwise it’ll highlight parts of normail email too. The way to disable again, though, is quitting Mutt...