A effective combo: diff + colordiff

diff and cvs diff is very important when programming; BTW, their output is not such user-friendly, even you use diff -urpN or diff -y or cvs diff -uRpN. Sometime you may hope to redirect their output to a text file and further more edit with VI; but this is not perfect since you need to run 2 different programs for a single simple task. At this moment, colordiff will be a good choice for you. Manual message from man colordiff:

colordiff is a wrapper for diff and produces the same output as diff but with coloured syntax highlighting at the command line to improve readability. The output is similar to how a diff-generated patch might appear in Vim or Emacs with the appropriate syntax highlighting options enabled. The colour schemes can be read from a central configuration file or from a local user ~/.colordiffrc file.

Install colordiff in Debian etch is very simple. Just run this command:

apt-get install colordiff

To test its powerful effect, let's compare 2 file with:

diff -urpN a.txt b.txt | colordiff | less -R

For sure that you can combine it with cvs diff, too. E.g.:

cvs diff -uRpN . | colordiff | less -R

So our next question should be: howto fully utilize colordiff in order to decrease our workload? Some simple bash shell script alias will give us a very handy help. Edit your ~/.bash_profile and add the following 2 lines, so replace diff as colordiff as default, and always display color with less:

alias diff='colordiff'
alias less='less -R'

The case of cvs diff is a bit more complicated. Here suggest for a handy function wrapper for simplify the work (Well, this seems not my cup of tea...). Add this to your ~/.bash_profile and run cvsdiff as replacement of cvs diff:

function cvsdiff () { cvs diff $@ | colordiff; }


Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <h1> <h2> <h3> <h4> <h5> <h6> <em> <strong> <code> <del> <blockquote> <q> <sub> <p> <br> <ul> <ol> <li> <dl> <dt> <dd> <a> <b> <u> <i> <sup> <acronym> <pre> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Images can be added to this post.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.