diff-so-fancy
is a diff
-highlighter designed for human eyeballs.
It removes the leading +
/-
which are annoying for cut/paste and makes clear sections between files.
Coloured git
(left) vs diff-so-fancy
(right - note the character-level highlights):
If you want thediff-so-fancy
(right side) output but not constrained to files in a git
repository, add the following function to your .bashrc
to use it on any files:
dsf() { git diff --no-index --color "$@" | diff-so-fancy; }
Eg:
dsf original changed-file
Character level highlighting and standard diff
format
If you don't like the non-standard formatting of diff-so-fancy
, but still want character-level git
highlighting, use diff-highlight
which will take git
's output and produce the really pretty standard diff
-format output:
To use it by default from git
, add to your .gitconfig
:
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
[pager]
diff = diff-highlight | less -FRXsu --tabs=4
The [pager]
section tells git
to pipe its already colourised output to diff-highlight
which colourises at the character level, and then pages the output in less (if required), rather than just using the default less
.