Colorised svn diffs

With the help of colordiff my svn diffing just got a whole lot prettier:
% svn diff --diff-cmd colordiff -x -w files |\
    less -RS
(I like to pass -w to the diff-er to ignore whitespace changes). Piping through less in raw mode (-r/-R) interprets the colour escape-sequences correctly.

Thanks to commandlinefu for the idea.


  1. Thanks for the great tip Mat.

    I was wondering whether this could get put into ~/.subversion/config somehow so that you just had to do a

    svn diff file

    command. From what I can see the labels have to be parsed to put then in quotes.

    So I created a little perl script (see below) called which I put in my binary area "~/bin", and edited my ~/.subversion/config so that it contains the line:

    diff-cmd = /bin/

    Anyway here is the perl script:


    my @args = ();
    my $L = 0;
    my $carg='';

    while (<@ARGV>) {
    if ($L==1) {
    $carg = $_;
    $carg ="\"".$carg;
    } elsif ($L>1) {
    $carg = $carg." ".$_;
    if (m/\)$/) {
    $carg = $carg."\" ";
    $L = 0;
    } else {
    } else {
    $carg = $_;
    if (m/^\-L/) {$L++;}
    push @args,$carg;

    system ("/usr/bin/colordiff -x -w -B @args");


Post a Comment

NAG moderates all replies and reserves the right to not publish posts that are deemed inappropriate.

Popular posts from this blog

Implied Volatility using Python's Pandas Library

C++ wrappers for the NAG C Library

ParaView, VTK files and endianness