5 ms·
Icdiff: side-by-side command line diffs
- yrmt 12y agoThere's also http://www.colordiff.org/ http://www.colordiff.org/
- selectnull 12y agoIt doesn't seem to be side by side, while icdiff is. Colors by themselved are not an issue as git supports it natively. Have I miseed something? edit: fix typo
- dima55 12y agodiff -y is side-by-side. As far as I know colordiff does per-line coloring, while icdiff seems to have finer granularity. This dude really should have patched colordiff, though. Or just used emacs.
- cbr 12y agocolordiff is just a perl script to colorize diff's output. Patching it to add support for the kind of coloring I want to do here would be a lot of work. As for using emacs, there are many cases when I want a stand-alone diff tool.
- selectnull 12y agoWow, all these years and I haven't known about diff -y. Thanks.
- cbr 12y agocolordiff looks like: http://www.colordiff.org/screen2.jpg http://www.colordiff.org/screen2.jpg It's just coloring the standard diff output so lines starting with > or + are yellow and ones starting with < or - are green. This is also what "git diff" does by default: http://www.jefftk.com/git-diff-color-2x.png http://www.jefftk.com/git-diff-color-2x.png icdiff is doing a side-by-side diff, and it's only coloring the changed sections of lines: http://www.jefftk.com/icdiff-side-by-side-2x.png http://www.jefftk.com/icdiff-side-by-side-2x.png
- mitchty 12y agoNot all that different than what you can achieve with git diff --color-words Example: http://i.imgur.com/smubTnH.png http://i.imgur.com/smubTnH.png
- cbr 12y agogit diff --color-words is good. Here's what that looks like on the same file: http://www.jefftk.com/diff-color-words-2x.png http://www.jefftk.com/diff-color-words-2x.png
- hrjet 12y agoOne more called cdiff: https://github.com/ymattw/cdiff https://github.com/ymattw/cdiff (works with repositories; not a general diff replacement.)
- givan 12y agoI use http://meldmerge.org http://meldmerge.org and besides syntax coloring it has filters for comments and whitespace, a 3 way file compare and folder compare that is very useful to see changes between code updates.
- cbr 12y agomeldmerge is great! But I also want something I can use on the command line.
- netheril96 12y agoMeld is the best diff/merge tool I have tried. But it relies on GTK, which relies on X, which looks terrible on Mac with retina screen.
- dima55 12y agoClearly the problem here does not lie with Meld.
- scott_karana 12y agoI don't think netheril96 blamed Meld at all. Nor OS X.
- _ZeD_ 12y agotry kdiff3 - http://kdiff3.sourceforge.net/ http://kdiff3.sourceforge.net/
- deleted 12y ago[deleted]
- ausjke 12y agoHad a quick try, looks awesome. it's quicker to do this on command line than vimdiff sometimes. I use meld for GUI and noticed it's not 100% accurate, sometimes they can not tell if two files are different, which is odd.
- userbinator 12y agoGNU 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
- Gonzih 12y agoMost of the time I use vimdiff to diff 2 files. Also allows you to push/pull differences from one buffer to another.
- kolme 12y agoVimdiff also support 3-way diffs. Git integration with fugitive is also worth mentioning. It makes partial committing and cherry picking very easy. Either way, icdiff looks very promising.
- cracoucax 12y agoLooks great, probably gonna add this to my toolkit.
- teddyh 12y agoWhen normal “diff” is not clear enough, I use Emacs and its built-in M-x ediff-files (or -buffers). It switches to side-by-side view with the “|” key.
- waxjar 12y agoI would suggest highlighting the line that changed as well, with a subtle background color. I mostly use GitGutter, a Sublime Text plugin that puts a symbol in the "gutter" (line numbers column) to indicate which lines changed, where one was deleted or where one was added. It works only on git repositories, though.
- cbr 12y agoUnfortunately "subtle" isn't really an option when working with standard terminal colors. There are only eight colors, and on most terminals it would be fair to describe all of them as "garish". A gutter symbol would be an option, though.
- waxjar 12y agoThat's a fair point. I did not consider the limited range of colours on most terminals. Bold text might also be an option, though it wouldn't immediately distinguish between added and removed characters.
- petepete 12y agoThe unfortunately named cdiff does this, I believe. https://github.com/ymattw/cdiff https://github.com/ymattw/cdiff
- shurcooL 12y agoNeat and useful. It reminds me of similar work I've done before at https://github.com/shurcooL/Conception-go/commit/02c5b49187d2989b6c648ee93f71cef15c6280d4#commitcomment-6927279 https://github.com/shurcooL/Conception-go/commit/02c5b49187d....
- jkaptur 12y agoVery cool! I love tools that provide better UX around diff - that show not just the shortest possible edit script, but a more human-readable output of what has actually changed. I've been prototyping some ideas in a web app: http://diff.so http://diff.so.
- xixixao 12y agoThis is great, is there a way to use it with Git? Edit: It also pains me that this is not the default (or one of the two default) diff views almost anywhere. The best diff I've used was in Phabricator. But Google, Github and Git don't have a support for side-by-side diffs, which I'd argue are the best view in 90% of incremental changes.
- archgoon 12y agoYes. In the repo there is a file 'git-icdiff' which runs the following command: git difftool --no-prompt --extcmd icdiff "$@" So you can use 'git icdiff' to get the icdiff display. In general, you can use git-difftool in conjunction with your diff displayer of choice.
- heydenberk 12y agoGitHub added added "split diffs" in September: https://github.com/blog/1884-introducing-split-diffs https://github.com/blog/1884-introducing-split-diffs
- masklinn 12y agoGithub implemented split diff 3 months ago: https://github.com/blog/1884-introducing-split-diffs https://github.com/blog/1884-introducing-split-diffs
- xixixao 12y agoHmm, seems I was overly optimistic. This fails with two words only on one line, highlights the words "red" and "blue" as being composed of each other and so on. Back to git difftool --color-words
- cbr 12y agoSorry, could you give an example input icdiff performs poorly on? I just tried it on "red" and "blue", and got http://www.jefftk.com/icdiff-red-blue-2x.png http://www.jefftk.com/icdiff-red-blue-2x.png which seems pretty reasonable to me.
- kickingvegas 12y agoFWIW, with emacs you can use ediff and then type '|' to change to a side-by-side view. ediff will also work with SCM (git, svn, etc.) as well.
- cgrinds 12y agoIt costs a few bucks but BeyondCompare http://www.scootersoftware.com/ http://www.scootersoftware.com/ is the best differ I've used. It's not terminal based, but is supported on Windows, Mac, and Linux.
- kolev 12y agoThis is a great little gem! It will replace colordiff in my scripts.
- Wildgoose 12y agoThis is a great tool. I work on Unix (without X) from Windows and so often have to ftp files about just to use Meld, which is my usual preferred diff tool. But I can use icdiff in a PuTTY session with a coloured xterm and get a sensible and clear diff comparison. Thanks! I really appreciate this!
- seewhat 12y agoAnother suggestion, if you haven't ruled it out. I enjoy using console vimdiff in PuTTY, because my configuration allows quick navigation without too much thought. The accumulated time for starting vim can become annoying when iterating over many files. (I could investigate loading diff pairs into tabs if I was sufficiently bothered.) Helpful .vimrc settings:- Firstly, map some keys to navigate to preceding/successive differences... " Next/ previous diff (analogous to j/k, use the same fingers) nmap <F6> ]czt nmap <F7> [czt And some helper keys... " Diff update, i.e. repaint the screen when needed nmap <F5> :diffupdate<CR> " Get from Buffer 1/ 2/ 3/ 4 nmap <F1> :diffget 1<CR> nmap <F2> :diffget 2<CR> nmap <F3> :diffget 3<CR> nmap <F4> :diffget 4<CR> Configure all visible windows when starting via vimdiff or diffthis. I prefer no folding (for added context) and then to navigate with the above keys. " Apply window-local settings to all diff windows au! FilterWritePost * if &diff | set wrap | set foldcolumn=0 | set nofoldenable | endif Finally, set some colors... " Override the diff colours highlight DiffAdd term=reverse cterm=NONE ctermbg=darkblue ctermfg=white highlight DiffDelete term=reverse cterm=NONE ctermbg=black ctermfg=blue highlight DiffChange term=reverse cterm=NONE ctermbg=darkgray ctermfg=white highlight DiffText term=reverse cterm=bold ctermbg=brown ctermfg=white Not implemented here is a toggle to ignore whitespace changes (perhaps mapped to <F8>).
- denulu 12y agoI've been using `dwdiff -c`, which admittedly doesn't do side-by-side: http://linux.die.net/man/1/dwdiff http://linux.die.net/man/1/dwdiff