# diff-so-fancy — Good-Looking Diffs for git and plain text > diff-so-fancy strips filenames, strips leading `+/-`, highlights word-level changes, and turns ugly unified diffs into clean, GitHub-style readable output — a drop-in replacement for git's default diff. ## Install Save in your project root: # diff-so-fancy — Good-Looking Diffs for git and plain text ## Quick Use ```bash brew install diff-so-fancy # Configure git once git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX" git config --global interactive.diffFilter "diff-so-fancy --patch" git config --global color.ui true 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" # Now every `git diff` is pretty ``` ## Introduction `diff-so-fancy` post-processes git's diff output to collapse filename headers, colorize hunk ranges, highlight intra-line word changes, and trim the leading `+`/`-` columns. It's written in Perl (now with a pre-built Node distribution) and reads from stdin, so it composes with any git or plain diff pipeline. ## What diff-so-fancy Does - Rewrites git-style unified diffs into a condensed, readable layout. - Highlights word-level changes in a line. - Strips the leading plus/minus gutter so code selects cleanly. - Integrates as git's `core.pager` or `interactive.diffFilter`. - Works with any tool that emits unified diff (svn, diff -u). ## Architecture Overview diff-so-fancy is a filter: it reads diff stdin, runs a line-by-line state machine distinguishing meta/hunk/added/removed/unchanged lines, applies ANSI color codes, and writes to stdout. Word highlighting uses `git diff-highlight` internally (bundled). ## Self-Hosting & Configuration - Install via brew, apt, pacman, or `npm install -g diff-so-fancy`. - Configure via `git config` — see Quick Use above. - `--patch` mode strips color for pager-pickers like fzf. - Pair with `less -RFX` to keep colors and quit on short diffs. ## Key Features - Drastically cleaner reviews — filename only at top of section. - Word-level diff highlight. - Zero config beyond `git config`. - Works with GitHub CLI (`gh pr diff | diff-so-fancy`). - Fast — Perl/Node pipe, negligible overhead. ## Comparison with Similar Tools - **delta (dandavison)** — Rust, more features (syntax-highlight, side-by-side). - **git diff-highlight** — built-in; word highlights but less polished. - **icdiff** — side-by-side Python tool. - **git --word-diff** — built-in word diff; less pretty. - **meld/kdiff3** — GUI tools for three-way merges. ## FAQ **Q: Which is "better", delta or diff-so-fancy?** A: delta is more featureful; diff-so-fancy is lighter and works everywhere Perl/Node does. **Q: Does it support side-by-side?** A: No — stick with delta or icdiff for that. **Q: Broken with `less`?** A: Use `less --tabs=4 -RFX` as shown. **Q: Can I disable word highlighting?** A: `diff-so-fancy --colors="keepEmptyLines,stripLeadingSymbols"`. ## Sources - https://github.com/so-fancy/diff-so-fancy --- Source: https://tokrepo.com/en/workflows/43fc75b0-38c4-11f1-9bc6-00163e2b0d79 Author: AI Open Source