tags:

views:

32

answers:

1

Hello! I’d like svn diff to display colored diff through a pager (just like git does). I’ve succeeded to get a colored diff by setting the diff-cmd in ~/.subversion/config:

diff-cmd = colordiff

Now I’d like to pipe the diff output through a pager, how do I do that? (Short of writing svn diff | less, of course.)

+1  A: 

In the past I've used a wrapper script and set diff-cmd to this script:

#!/bin/sh
colordiff "$@" | less -r

But then you get a separate pager for every file, I'm not sure if this is what you want. Nowadays I just write svn diff | less.

Another easy solution is making an alias: alias svndiff='svn diff | less'. Or if you want to use svn diff, make a shell function:

svn() {
    if [ x"$1" = xdiff ] || [ x"$1" = xdi ]; then
        /usr/bin/svn "$@" | less -r
    else
        /usr/bin/svn "$@"
    fi
}
schot