-
Install
colordiff
using Homebrew:brew install colordiff
-
Add function to your
~/.bash_profile
:cat <<EOF >>~/.bash_profile function diff { colordiff -u "$@" | less -RF } EOF
-
Change default output colours to match git:
cat <<EOF >~/.colordiffrc newtext=green oldtext=red diffstuff=cyan EOF
-
Reload:
. ~/.bash_profile
-
Profit.
Notes on switches:
-u
indiff
means: unified diff-R
inless
means: show raw escape codes (so we can see the colour)-F
inless
means: quit if entire output fits on one screen
Another comment many years down the line:
This doesn't work if you have really short diffs, as less will automatically quit out and not leave a history when the length can be displayed on screen.
If you are willing to scroll, I'd just make a new function (not replacing diff directly).
Also @gf3's comment is not true. git diff is not made to compare multiple files and will just show a blank screen with
(END)
at the top.Review: http://stackoverflow.com/questions/13964328/git-diff-two-files-on-same-branch-same-commit