Skip to content

so-fancy/diff-so-fancy

Folders and files

Name
Last commit message
Last commit date

Latest commit

36dcfde · Sep 18, 2024
May 18, 2021
Mar 4, 2024
May 31, 2021
Sep 18, 2024
Dec 20, 2023
May 18, 2021
May 26, 2021
Aug 23, 2016
Apr 15, 2024
May 18, 2021
Sep 18, 2024
Feb 26, 2024
Jan 22, 2022
Mar 20, 2024
Jul 5, 2017
Jul 27, 2021
Jul 27, 2021
Apr 2, 2024
Jun 9, 2023
Jun 9, 2023
Mar 20, 2024

Repository files navigation

diff-so-fancy Circle CI build TravisCI build AppVeyor build

diff-so-fancy strives to make your diffs human readable instead of machine readable. This helps improve code quality and helps you spot defects faster.

Screenshot

Vanilla git diff vs git and diff-so-fancy

diff-highlight vs diff-so-fancy

Install

Simply copy the diff-so-fancy script from the latest release into your $PATH and you're done. Alternately to test development features you can clone this repo and then put the diff-so-fancy script (symlink will work) into your $PATH. The lib/ directory will need to be kept relative to the core script.

If you are using a ZSH framework like zgenom or oh-my-zsh, refer to Zsh plugin support for diff-so-fancy for detailed installation instructions.

diff-so-fancy is also available from the NPM registry, brew, as a package on Nix, Fedora, in the Arch extra repo, and as ppa:aos for Debian/Ubuntu Linux.

Issues relating to packaging ('installation does not work', 'version is out of date', etc.) should be directed to those packages' own repositories/issue trackers where applicable. Issues relating to packaging ("installation does not work", "version is out of date", etc.) should be directed to those packages' repositories/issue trackers where applicable.

Note: Windows users may need to install MinGW or the Windows subsystem for Linux.

Usage

With git

Configure git to use diff-so-fancy for all diff output:

git config --global core.pager "diff-so-fancy | less --tabs=4 -RF"
git config --global interactive.diffFilter "diff-so-fancy --patch"

Improved colors for the highlighted bits

The default Git colors are not optimal. The colors used for the screenshot above were:

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"

git config --global color.diff.meta       "11"
git config --global color.diff.frag       "magenta bold"
git config --global color.diff.func       "146 bold"
git config --global color.diff.commit     "yellow bold"
git config --global color.diff.old        "red bold"
git config --global color.diff.new        "green bold"
git config --global color.diff.whitespace "red reverse"

With diff

Use -u with diff for unified output, and pipe the output to diff-so-fancy:

diff -u file_a file_b | diff-so-fancy

It also supports the recursive mode of diff with -r or --recursive as first argument

diff -r -u folder_a folder_b | diff-so-fancy
diff --recursive -u folder_a folder_b | diff-so-fancy

Options

markEmptyLines

Should the first block of an empty line be colored. (Default: true)

git config --bool --global diff-so-fancy.markEmptyLines false

changeHunkIndicators

Simplify git header chunks to a more human readable format. (Default: true)

git config --bool --global diff-so-fancy.changeHunkIndicators false

stripLeadingSymbols

Should the pesky + or - at line-start be removed. (Default: true)

git config --bool --global diff-so-fancy.stripLeadingSymbols false

useUnicodeRuler

By default, the separator for the file header uses Unicode line-drawing characters. If this is causing output errors on your terminal, set this to false to use ASCII characters instead. (Default: true)

git config --bool --global diff-so-fancy.useUnicodeRuler false

rulerWidth

By default, the separator for the file header spans the full width of the terminal. Use this setting to set the width of the file header manually.

git config --global diff-so-fancy.rulerWidth 80

The diff-so-fancy team

Person Role
@scottchiefbaker Project lead
@OJFord Bug triage
@GenieTim Travis OSX fixes
@AOS Debian packager
@Stevemao/@Paul Irish NPM release team

Contributing

Pull requests are quite welcome, and should target the next branch. We are also looking for any feedback or ideas on how to make diff-so-fancy even fancier.

Other documentation

Alternatives

License

MIT