Thursday, September 29, 2011

Colored svn diff

svn diff command shows the differences between two versions of the file. If you want to get the nice, colored output of this command just do:

  1. Install colordiff (eg. on Ubuntu):
    sudo apt-get install colordiff
  2. Simply redirect svn diff output to colordiff:
    svn diff -r Rev1:Rev2 file | colordiff
  3. You can declare a simple function in your ~/.bashrc file:
    svndiff() {
    svn diff "${@}" | colordiff
    }
  4. To test your new svndiff function run:
    svndiff -r Rev1:Rev2 file
  5. To color longer outputs you can use vi editor:
    svn diff -r R1:R2 file | vim -

1 comment:

  1. you can add this to the end of your .bashrc and use svn diff (previusly install colordiff)

    svn()
    {
    /usr/bin/svn "${@}" | colordiff | less -R
    }

    ReplyDelete