Working on the command line using either git or hub can be quite a bland experience, and often a user can find it difficult when reading diffs. Now, the standard format of git has been replaced by a much better console output utility. Diff-so-fancy is a tool that's used to colourize text and enhance its appearance.
Diff-so fancy improves your diff viewing experience and makes your text output more human-readable, unlike the standard git which appears cryptic. It comes with improved text highlighting and removes the + and – characters that precede diffs. This simplifies copy-pasting your diffs in a cleaner and more readable format and enables you to keep track of file changes with file headers.
For Debian 7 & Ubuntu 17.04
Type the following command into your command line
This installs NPM which is a Node.js package manager that will enable you to handle JSON files that come bundled in diff-so-fancy. A good example is package.json file that comes zipped alongside other files from GitHub.
Fire up the command below to install diff-so-fancy with npm
npm install -g diff-so-fancy
/usr/local/bin/diff-so-fancy -> /usr/local/lib/node_modules/diff-so-fancy/diff-so-fancy /usr/local/lib └── email@example.com
After installing, simply pipe your Git diffs to diff-so-fancy for an improved diff view.
git diff --color | diff-so-fancy
Configuring git to use diff-so-fancy
git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX" git config --global pager.show "diff-so-fancy | less --tabs=1,5 -RFX"
Setting diff-so-fancy colours to colourize diffs
Default colours aren’t always the best and you may opt for more fancier text outputs to improve the appearance of text. Below are some commands that can come in handy to help you achieve this
git config --global color.ui true git config --global color.diff-highlight.oldNormal "red bold" git config --global color.diff-highlight.oldHighlight "red bold 52" git config --global color.diff-highlight.newNormal "green bold" git config --global color.diff-highlight.newHighlight "green bold 22"
Comparisons between git diff and git diff | diff-so-fancy
git diff | diff-so-fancy
In the first image, we see the ++ and - - characters in line 2, 4 & 5. In the second image, these characters have been replaced by a simple header thereby enhancing the readability of diffs.
Piping git diff to diff-so-fancy
git diff | diff-so-fancy
In the above example, the colorization of diffs enables the developer to keep track of his diffs visually by colour coding.
The diff-so-fancy tool main objective is to give a user easier time when checking out diffs. This saves up on time and greatly increases productivity on the part of the developer.