unified形式のdiffに色付けする

Rubyワンライナーで書いてみた。

$_.gsub!(/^[-+@]/) {|m| "\x1b[1;%sm#{m}" % {"-" => 31, "+" => 34, "@" => 35 }[m] }

こんな感じ。


svn diff -c147 svn+ssh://winebarrel@rubyforge.org/var/svn/zipruby/ | ruby -p -e '$_.gsub!(/^[-+@]/) {|m| "\x1b[1;%sm#{m}" % {"-" => 31, "+" => 34, "@" => 35 }[m] }' | lv