Wednesday, February 3, 2010

Highlighted patches inside mutt

Tons of patches are delivered by mailing lists. Unfortunately, there is not a native way how properly highlight patches inside mutt. This problem could be resolved by two different methods:

1) call an external command for diffs. You need something like
  text/x-diff;  cat %s | colordiff;copiousoutput
text/x-patch; cat %s | colordiff;copiousoutput
in your ~/.mailcap and

  auto_view text/x-diff
auto_view text/x-patch
set allow_ansi
in your ~/.muttrc. Unfortunately this method sucks, because a lot of patches are distributed in the body of the mail. Note that the mail body is usually better for patches that attachments (see The Perfect Patch).

2) use mutt highlighting. This method is also not perfect, but I use it for years and I am very happy with it. You need to add
  color body green default "^diff \-.*"
color body green default "^index [a-f0-9].*"
color body green default "^\-\-\- .*"
color body green default "^[\+]{3} .*"
color body cyan default "^[\+][^\+]+.*"
color body red default "^\-[^\-]+.*"
color body brightblue default "^@@ .*"
to you ~/.muttrc. That's all :-)

1 comment:

  1. I was looking for a decent color highlighting scheme for when I'm lazy, so thanks.

    However for when I'm not lazy, you can pipe patches from the mail body into an external program like colordiff using | when in the mail view mode.

    ReplyDelete