Skip to content

Guide · Open source

How to use diff-so-fancy: git setup, diff output and options

Updated · written with AI from the project's own documentation and checked against our catalogue data

diff-so-fancy is a command-line script, licensed under MIT and written in Perl, that reformats the text output of diff tools such as git diff so changes are easier to scan. It adds color, simplifies headers and hides the leading + and - symbols. This guide shows you how to install it, connect it to git, pipe plain diff output through it, and adjust its options.

diff-so-fancyso-fancy/diff-so-fancy · ★ 18.1k · MIT

Quick start

  1. 1Check Perl. Confirm Perl is installed, since the project is written in Perl.
  2. 2Install the script. Copy the diff-so-fancy script from the latest GitHub release into a directory on your $PATH.
  3. 3Set the git pager. Run the git config command that sets core.pager to diff-so-fancy piped into less.
  4. 4Set the interactive diff filter. Run the git config command that sets interactive.diffFilter to diff-so-fancy --patch if you use git add -p style patch mode.
  5. 5Test with git diff. Run git diff in a repository with changes and check that the output shows colors, simplified headers and no leading + or - symbols.
  6. 6Adjust options if needed. Use git config with the diff-so-fancy. prefix to change defaults such as stripLeadingSymbols or rulerWidth.

What you need before you install diff-so-fancy

diff-so-fancy is a Perl project, so Perl is the prerequisite listed in the project source. You also need a terminal and, for the git setup, git itself. The tool only formats text output, so it works only for people who use the terminal.

  • Perl installed on your system
  • A terminal and command-line git, if you want to use it with git
  • Plain diff -u output, if you want to use it without git

Install diff-so-fancy

The README says you can copy the diff-so-fancy script from the latest GitHub release into your $PATH and you are done. To test development features, you can instead clone the repository and put the diff-so-fancy script into your $PATH; a symlink works. The lib/ directory must stay relative to the core script.

The project is also available from the NPM registry, Homebrew, Fedora, the Arch extra repo, and a PPA for Debian and Ubuntu. Packaging issues should go to those packages' own repositories.

  • Download the script from the latest release on GitHub and place it in your $PATH
  • For development features, clone the repository and symlink the script into your $PATH, keeping lib/ next to it
  • Or install through a package source listed in the README
git clone https://github.com/so-fancy/diff-so-fancy

Set git to use diff-so-fancy as its pager

To use diff-so-fancy for all git diff output, set it as the global pager. The pager setting pipes git output through diff-so-fancy and then into less with tab width and color options.

To also use it in interactive patch mode, set the diff filter as well.

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

Pipe plain diff output into diff-so-fancy

If you compare files with diff, use the -u flag for unified output and pipe the result into diff-so-fancy. The README also notes support for recursive comparison of folders with -r or --recursive.

diff -u file_a file_b | diff-so-fancy diff --recursive -u /path/folder_a /path/folder_b | diff-so-fancy

Change diff-so-fancy options with git config

Each option is set with git config under the diff-so-fancy name. The README lists these defaults and effects:

  • markEmptyLines (default true): colorizes the first block of an empty line
  • changeHunkIndicators (default true): simplifies Git header chunks to a human-readable format
  • stripLeadingSymbols (default true): removes the + or - at the start of each diff line
  • useUnicodeRuler (default true): draws ruler lines with Unicode; false uses ASCII
  • rulerWidth (default: screen width): sets the width of ruler lines
  • fileNameRulerShape (default box): set to ruler for full-width ruler lines around file names in git show output
  • shortHeaders (default false): shows filename and line number on a single line
  • semIntegration (default false): includes the summary from sem in the header for each changed file
git config --bool --global diff-so-fancy.stripLeadingSymbols false git config --global diff-so-fancy.rulerWidth 80

What people use it for

  • Reviewing many diffs in the terminal before committing code
  • Reading git show output with clearer file name rulers
  • Comparing two files or folders with diff -u and scanning the changes quickly
  • Staging parts of a file in interactive patch mode with a more readable diff

Frequently asked questions

Is diff-so-fancy free to use?

Yes. The project is licensed under MIT, as stated in its README and in the project listing. You can use, copy and modify it under those terms.

What do I need to run diff-so-fancy?

The project requires Perl, since it is written in Perl. You also need a terminal, and command-line git if you want to use it as a git pager.

How do I install diff-so-fancy?

Copy the diff-so-fancy script from the latest GitHub release into your $PATH. The README also lists NPM, Homebrew, Fedora, the Arch extra repo and a Debian/Ubuntu PPA as sources.

How do I make git use diff-so-fancy?

Run git config --global core.pager "diff-so-fancy | less --tabs=4 -RF". To use it in interactive patch mode, also run git config --global interactive.diffFilter "diff-so-fancy --patch".

Can diff-so-fancy show syntax-aware or structural diffs?

No. The README describes only line-based formatting. If you need syntax-aware or structural diffs, the project's listed alternatives include difftastic and Delta.

How does diff-so-fancy compare with Delta or difftastic?

The source lists Delta, Lazygit and difftastic as comparable projects but does not benchmark them against diff-so-fancy. diff-so-fancy is a simple drop-in script that formats line-based text output, while difftastic is a structural diff tool.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

diff-so-fancy suits developers who read many git or diff -u outputs in a terminal and want a simple setup with no complex configuration. It is a poor fit if you do not use a terminal, want syntax-aware diffs, or need the exact raw diff text, in which case consider difftastic or Delta.

Install options & downloads