I learned about difftastic today, which aims to show differences between files while being aware of the underlying programming language used in said files (if any).
It’s basically magic when it works!
I generally like the built-in diff in the JetBrains suite of IDEs. The one I use these days is GoLand, but I believe they all support adding an external diff tool. Since difftastic is a console app, here’s what I had to do on my Mac:
brew install difftastic # install the tool
- Install ttab using their brew instructions. This allows GoLand to launch a new tab in iTerm and run the
difft
command there. Otherwise, using the External Diff Tool in Goland would appear to do absolutely nothing, as the output of the tool isn’t displayed natively. - Configure the external diff tool using the instructions for GoLand.
- Program path:
ttab
- Tool name:
Difftastic
(but can be anything you like) - Argument pattern:
-a iTerm2 difft %1 %2 %3
- The “-a iTerm2” is to ensure that iTerm is used instead of the default Terminal app.
- Program path:
Now you can click this little button in the standard GoLand diff view to open up the structural diff if needed:
Ideally the diff would be integrated into GoLand, but I don’t mind it being an extra click away, since difftastic doesn’t work reliably in many situations (particularly large additions or refactorings).