Take the 2-minute tour ×

Instead of running "svn diff", "hg diff" and so on .. can we write a single command that calls svn/hg/git accordingly? Can the diff output be made pretty?

edit: command-line tools (not GUI) preferred.

share|improve this question
Better suited at SO ? –  Sathya Jan 18 '10 at 6:04
add comment

migrated from superuser.com Jan 18 '10 at 6:08


3 Answers

There are also a number of "wrap all the common VCS commands into one utility" projects. pyvcs and UVC are two that come to mind. Maybe these would do what you want?

share|improve this answer
pyvcs package does not seem to install any scripts; is it only providing an abstract API? –  Sridhar Ratnakumar Jan 19 '10 at 7:24
Woh, but I guess you are right. My bad. –  RyanWilcox Jan 19 '10 at 23:49
Thank you for the UVC reference, I have updated my script to use UVC. –  Sridhar Ratnakumar Jan 20 '10 at 17:26
add comment
up vote 3 down vote accepted

Typing "svn diff" or "hg diff" is no fun if you had to type it again just to page the output with less. Further, when it is likely that your text editor does syntax highlighting .. there is no reason why the diff output in the terminal should not also be highlighted with appropriate colors.

alt text

You will need colordiff which can be installed via apt or macports.

The following bash function will enable one to type just `dif' under the working directory of the VCS of your choice (no need to specify whether it is hg or svn).

function dif {
   if [ -d .hg ]; then
   elif [ -d .svn ]; then
       echo "cannot find VC type"
       return 1
   $VC diff $1 | colordiff | less -R

It should be easy to add support for other VCS tools (git, cvs, etc..)

Additionally if you have UVC installed (as per Ryan Wilcox's answer), the above script can be simplified as:

function dif {
   uvc diff $1 | colordiff | less -R
share|improve this answer
you can collapse your test and if statements: if [ -d .hg ]; then also you should balance out your if by using if...elif...else (or use a case statement). –  Dennis Williamson Jan 18 '10 at 10:26
Thx, I modified the code. –  Sridhar Ratnakumar Jan 18 '10 at 22:45
add comment

Try Diffuse. It will figure out the appropriate version control system and display diffs with nice syntax highlighting.

share|improve this answer
add comment

Your Answer


