Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Side-by-side color diff at terminal using CDiff

📅 2013-Aug-24 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cdiff, diff, git, mercurial, subversion ⬩ 📚 Archive


If you use Mercurial, Git or Subversion at the shell, CDiff is a useful tool to have around. By default, hg diff or git diff is displayed in the classic diff format. This shows the before-and-after changed lines one below the other. Personally, I find this very confusing. I very much prefer the side-by-side diff view used in GUI diff programs. cdiff is a great way to get this side-by-side diff view at the shell in full color!


CDiff is a Python program that can be installed from PyPI using this command:

$ sudo pip install cdiff

Note: Do not confuse this package with the colordiff package that is available in Ubuntu repositories. That is something else!


$ diff -u file1.cpp file2.cpp | cdiff -s

Tried with: CDiff 0.9.7, Python 2.7.6 and Ubuntu 14.04