-
Install
colordiffusing 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:
-uindiffmeans: unified diff-Rinlessmeans: show raw escape codes (so we can see the colour)-Finlessmeans: quit if entire output fits on one screen
Just checked
git diffwith two files not belonging to any a Git repo (current directory is not a repo tree either), and it works for me. This is with Git 2.19.1 on macOS.