5 ms·
GNU diff has the -y option that already does side-by-side diffs; I'm a bit surprised that it doesn't do colouring already.
by userbinator 12y ago
GNU diff has the -y option that already does side-by-side diffs; I'm a bit surprised that it doesn't do colouring already.
- andyidsinga 12y agoI've used that a lot over the years ..and wished the same thing. hell, less can even do color with -R
- __michaelg 12y agoJust use colordiff, `colordiff -y`works perfectly fine.
- cbr 12y ago"colordiff -y" colors whole changed lines: http://www.jefftk.com/icdiff-vs-colordiff-y-2x.png http://www.jefftk.com/icdiff-vs-colordiff-y-2x.png
- glitch 12y agoA picture is perhaps worth at least a few hundred words... http://i.imgur.com/VOlbMoy.png http://i.imgur.com/VOlbMoy.png icdiff seems to have the best defaults for me.
- zobzu 12y agoSo much time would be saved if ppl did a google search before writing tools :) (its fine to reimplement, test, learn etc. But sometimes I really wonder ;)
- jefftk 12y agoBefore I wrote this, back in 2009 [1], I looked for existing tools that would do this already. I found colordiff and cdiff, but neither of them would highlight the parts of lines that had changed. Not finding anything that did what I wanted, I wrote something. [1] http://www.jefftk.com/p/introducing-icdiff http://www.jefftk.com/p/introducing-icdiff
- zobzu 12y agocontributing to something seems like a better effort, tho.
- Retra 12y agoYou would think that would be a solution, but sometimes learning to use a tool is about as hard as writing the tool yourself. (And in a few special cases, it's even more difficult!) Not that this applies here, but it is something to consider.
- chjj 12y agoNot for a side-by-side diff, but I just use this for color diffs: cdiff() { diff -u "$@" \ | sed 's/^\(@@ .* @@\)$/'$'\e[36m''\1'$'\e[m''/g' \ | sed 's/^\(-.*\)$/'$'\e[31m''\1'$'\e[m''/g' \ | sed 's/^\(+.*\)$/'$'\e[32m''\1'$'\e[m''/g' \ | less -c -R }
- cbr 12y agoYour cdiff colors lines by whether they're added or removed: http://www.jefftk.com/cdiff-shell-function-2x.png http://www.jefftk.com/cdiff-shell-function-2x.png icdiff colors just the part of the line that changed: http://www.jefftk.com/icdiff-comparison-1234a1234.png http://www.jefftk.com/icdiff-comparison-1234a1234.png