# diff-so-fancy

> Perl script that reformats git diff and unified diff output for readability, with cleaner headers, hunk markers, and stripped +/- symbols.

Stars: 18.1k · Language: Perl · License: MIT · Categories: Git

- Repository: https://github.com/so-fancy/diff-so-fancy
- Page: https://www.trmn.sh/tools/diff-so-fancy

## Overview

diff-so-fancy is a diff post-processor. It reads unified diff output, either from git or from the standard `diff -u` command, and reformats it to be easier to read. It is used as a pager filter for git, or at the end of a pipe such as `diff -u file_a file_b | diff-so-fancy`. Recursive diffs are supported too: `diff --recursive -u /path/folder_a /path/folder_b | diff-so-fancy`.

For git, you set it as the core pager with `git config --global core.pager "diff-so-fancy | less --tabs=4 -RF"`. You can also set it as the interactive diff filter with `git config --global interactive.diffFilter "diff-so-fancy --patch"`. The output simplifies git's hunk header chunks, draws ruler lines around file names, can remove the leading `+` and `-` symbols, and colorizes the first block of empty lines.

Behavior is controlled through `git config` keys under the `diff-so-fancy.` namespace. These are markEmptyLines, changeHunkIndicators, stripLeadingSymbols, useUnicodeRuler, rulerWidth, fileNameRulerShape, shortHeaders and semIntegration. shortHeaders collapses the file name and line number into a single line. semIntegration adds the summary from the `sem` tool to the header of each changed file. The README lists Delta, difftastic, and Lazygit (which has a diff-so-fancy integration) as related tools. The tool is aimed at developers who read diffs in the terminal.

![diff-highlight vs diff-so-fancy](https://media.trmn.sh/cached/256f83deb74156588bee362145985f4c9b2cde4c1add1b482991a31706821822.png)

## Alternatives

- [Git Extras](https://www.trmn.sh/tools/git-extras.md): A collection of extra git subcommands, including git-ignore, git-setup, git-changelog, git-release, git-effort, git-squash and git-pull-request. (Shell, 18.1k stars)
- [pre-commit](https://www.trmn.sh/tools/pre-commit.md): Framework for managing and maintaining multi-language pre-commit hooks in Git repositories. (Python, 15.7k stars)
- [git-lfs](https://www.trmn.sh/tools/git-lfs.md): Git extension for managing large files by storing them outside the repository with pointer files (Go, 14.6k stars)
- [gitui](https://www.trmn.sh/tools/gitui.md): Terminal-based Git GUI for staging, committing, branching, and repository management with keyboard-only control (Rust, 22.6k stars)
- [git-secrets](https://www.trmn.sh/tools/git-secrets.md): Prevents committing passwords and sensitive information to git repositories using pattern matching and hooks (Shell, 13.4k stars)

---

Canonical: https://www.trmn.sh/tools/diff-so-fancy
