-
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
I suppose it's not related to git but if you want similar diffs and have VIM there is another solution shown here.
diff file1 file2 | vim -R -
-or-
diff file1 file2 | view -
.The
view
command is same asvim -R
.