Please note this question is not a duplicate of, but a followup to the question "How can I get a side-by-side diff when I do “git diff”?". This question seeks new information and the solution to a problem.
Also, please note that I am seeking only solutions whose output is inline in the terminal like the default git diff
is -- I don't want anything which opens an external gui diff program.
I have followed the suggestion from the SO question linked above and put the following executable on my path:
#!/bin/bash
# side-by-side diff with custom options:
sdiff -w200 -l "$2" "$5"
I can then test it like so, for example:
GIT_EXTERNAL_DIFF=mydiff git diff HEAD HEAD~1
and I'll get output like this:
As intended, this is:
However, it has a couple problems:
fatal: external diff died, stopping at <filename>
Is there a way to remedy those two issues with sdiff
? If not, is there a way to do it with /usr/bin/diff
, the built in git diff program, or another terminal program? I don't care how I accomplish the goal. I just want inline, side by side diffs with color.
[THIS] worked fine for me, even with colors. (Thanks @ github.com/cockroachdb/cockroach)
If your terminal has issues displaying colors with sdiff, you probably want to pipe sdiff to colordiff like:
sdiff -w200 -l "$2" "$5" | colordiff | grep -E ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With