需先把 diff-so-fancy 脚本放进 $PATH,克隆仓库时 lib/ 目录必须与主脚本保持相对位置;通过 brew、npm、Fedora、Arch 等包管理器安装的版本问题需找对应打包仓库;多个行为由 git config 开关控制,默认值可能与预期不同
diff-so-fancy
so-fancyMIT活跃维护把 Git diff 输出重新排版成更易读的格式,突出改动位置和代码块,方便快速定位缺陷、提升代码审查效率。
Make your diffs human readable for improved code quality and faster defect detection. :tada:
git config --global core.pager "diff-so-fancy | less --tabs=4 -RF"
git config --global interactive.diffFilter "diff-so-fancy --patch"README 未说明,纯文本处理脚本,无特殊硬件要求
把机器可读的 git diff 变成人眼易读的彩色输出,帮你更快发现代码缺陷
把 Git diff 输出重新排版成更易读的格式,突出改动位置和代码块,方便快速定位缺陷、提升代码审查效率。
核心能力
- 重排 diff 输出,让改动更易读
- 简化 hunk 头部为人类可读格式
- 去掉每行开头的 + 和 - 符号
- 用 Unicode 绘制分隔线,宽度可配置
- 可作为 git 的 pager 和 interactive.diffFilter 使用
容易踩的坑
- v1.4.14最新正式版2026-10-03 · 2026-10-03 20:45 UTC
New features
- OSC 1717 diff-line metadata support for Lazygit — #538:
fileNameRulerShapeoption — #545, closes #522:- box (default) vs ruler shape for file names in git show mode.
- Terminal now reads from env
$COLUMNSbefore falling back totput— #556: --dateiso support — 27e0ce5 + test for #540:- Adds a simple
Makefile
Fixes
- Fix crash on git dates without timezone offset (log.date=local) — #544.
- Fix binary file parser when filename contains and — #547.
- Fix filename parsing when path contains b/ segment — #549.
- Fix crash on diff ending on truncated old mode line — #551.
- Fix strip_leading_indicators double-coloring raw diffs — #542.
- Harden Date: handling to skip when unixtime unparseable.
Docs
- Update LazyGit link to
Custom_DiffRenderers.md. package.jsonrepo URL- Bump actions/setup-node 4 -> 7 — #541.
- v1.4.122026-08-16 · 2026-08-16 17:07 UTC
查看更新说明
What's Changed
- Suppress Perl warning for 'use_color' variable in Dump::Krumo by @cgrothaus in https://github.com/so-fancy/diff-so-fancy/pull/527
- Fix broken link to sem project in README by @nicolasff in https://github.com/so-fancy/diff-so-fancy/pull/529
- Preserve remaining lines when splitting large diff chunks by @Haraguroicha in https://github.com/so-fancy/diff-so-fancy/pull/530
- Use long flag to be more self-explanatory by @churchilldu in https://github.com/so-fancy/diff-so-fancy/pull/533
- fix spelling mistakes by @hoxbro in https://github.com/so-fancy/diff-so-fancy/pull/534
- Fix patch mode line mismatch on added/deleted files by @arnaud-dezandee in https://github.com/so-fancy/diff-so-fancy/pull/535
- Bump actions/checkout from 6 to 7 by @dependabot[bot] in https://github.com/so-fancy/diff-so-fancy/pull/537
New Contributors
- @cgrothaus made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/527
- @nicolasff made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/529
- @Haraguroicha made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/530
- @churchilldu made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/533
- @hoxbro made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/534
- @arnaud-dezandee made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/535
Full Changelog: https://github.com/so-fancy/diff-so-fancy/compare/v1.4.10...v1.4.12
- v1.4.102026-04-09 · 2026-04-09 18:06 UTC
查看更新说明
This is a bugfix release to address #521
What's Changed
- Load Time::HiRes() on demand to speed up start time
- BUGFIX for
uninitialized value $add_color
Full Changelog: https://github.com/so-fancy/diff-so-fancy/compare/v1.4.8...v1.4.10
- v1.4.82026-03-27 · 2026-03-27 22:30 UTC
查看更新说明
What's Changed
- add proper guide for publishing to npm by @paulirish in https://github.com/so-fancy/diff-so-fancy/pull/510
- Link install instructions to releases page. by @falsifian in https://github.com/so-fancy/diff-so-fancy/pull/513
- Fix a corner case with a one line diff breaking
--patchmode - Various README updates
- add
--shortHeadersas an option to use less screen real estate - BUGFIX: correct
Use of uninitialized value $ENV{"USER"} - BUGFIX: single line input was not making it through d-s-f
- Update unit tests to use
ansi-reveal.plto simplify color testing - Cleaner logic in
get_diff_chunks()to make chunking smarter - High commit headers in
git showmode
New Contributors
- @falsifian made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/513
Full Changelog: https://github.com/so-fancy/diff-so-fancy/compare/v1.4.6...v1.4.8
- v1.4.62026-03-16 · 2026-03-16 18:03 UTC
查看更新说明
- d-s-f is much smarter and
--patchmode should work in more (all?) scenarios- Added support for enabling patch mode via
DSF_PATCH_MODEenvironment variable
- Added support for enabling patch mode via
- Added a new CLI option
--rulerWidth - Support ANSI reset without the 0.
\e[0mvs\e[m - Upstream
DiffHighlight.pmfixes. Allow "italic" in colors - Add some debug logging when started with
--debugto help troubleshooting - Support git file copies better if
diff.renames copiesis enabled in.gitconfig - Better support for recursive diff like:
diff -u -r /dir/a /dir/b
What's Changed
- Add Fedora to known packages by @principis in https://github.com/so-fancy/diff-so-fancy/pull/452
- README: distros: add Gentoo by @vitaly-zdanevich in https://github.com/so-fancy/diff-so-fancy/pull/456
- README: Gentoo package link: fix from commit to master by @vitaly-zdanevich in https://github.com/so-fancy/diff-so-fancy/pull/457
- docs: fix url to Nix package by @mikaello in https://github.com/so-fancy/diff-so-fancy/pull/459
- Add Fedora to known packages by @principis in https://github.com/so-fancy/diff-so-fancy/pull/471
- Update less invocation as of version 530 by @JacksonBailey in https://github.com/so-fancy/diff-so-fancy/pull/476
- Update Arch Linux package URL in README.md by @felixonmars in https://github.com/so-fancy/diff-so-fancy/pull/479
- Fix broken Nix package URL by @alexandear in https://github.com/so-fancy/diff-so-fancy/pull/481
- Make this loadable easily by ZSH frameworks by @unixorn in https://github.com/so-fancy/diff-so-fancy/pull/482
- Add awesomebot link checker by @unixorn in https://github.com/so-fancy/diff-so-fancy/pull/486
- Fix broken link in README.md by @unixorn in https://github.com/so-fancy/diff-so-fancy/pull/484
- chore: fix some typos by @vitalmotif in https://github.com/so-fancy/diff-so-fancy/pull/487
- fix: Incorrect incorrect title in pro-tips.md by @TakumiBC in https://github.com/so-fancy/diff-so-fancy/pull/488
- Fix minor typo. by @johnjohndoe in https://github.com/so-fancy/diff-so-fancy/pull/489
- Remove duplicate line in README by @Ben3eeE in https://github.com/so-fancy/diff-so-fancy/pull/505
- Make first 16 color bars narrower to avoid wrapping by @Cougar in https://github.com/so-fancy/diff-so-fancy/pull/502
- Update awesomebot and add dependabot by @unixorn in https://github.com/so-fancy/diff-so-fancy/pull/509
New Contributors
- @principis made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/452
- @vitaly-zdanevich made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/456
- @mikaello made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/459
- @JacksonBailey made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/476
- @felixonmars made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/479
- @alexandear made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/481
- @unixorn made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/482
- @vitalmotif made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/487
- @TakumiBC made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/488
- @johnjohndoe made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/489
- @Ben3eeE made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/505
- @Cougar made their first contribution in https://github.com/so-fancy/diff-so-fancy/pull/502
Full Changelog: https://github.com/so-fancy/diff-so-fancy/compare/v1.4.4...v1.4.6
- d-s-f is much smarter and
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
🎩 diff-so-fancy

diff-so-fancy makes 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

📦 Install
Simply copy the diff-so-fancy script from the latest Github 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.
diff-so-fancy is also available from the NPM registry, brew, 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' repositories/issue trackers where applicable.
✨ Usage
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"
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
We also support recursive mode with -r or --recursive
diff --recursive -u /path/folder_a /path/folder_b | diff-so-fancy
⚒️ Options
markEmptyLines
Colorize the first block of an empty line. (Default: true)
git config --bool --global diff-so-fancy.markEmptyLines false
changeHunkIndicators
Simplify Git header chunks to a human readable format. (Default: true)
git config --bool --global diff-so-fancy.changeHunkIndicators false
stripLeadingSymbols
Remove the + or - symbols at start of each diff line. (Default: true)
git config --bool --global diff-so-fancy.stripLeadingSymbols false
useUnicodeRuler
Use Unicode to draw the ruler lines. Setting this to false will use ASCII instead. (Default: true)
git config --bool --global diff-so-fancy.useUnicodeRuler false
rulerWidth
rulerWidth sets the width of the ruler lines. (Default: screen width)
git config --global diff-so-fancy.rulerWidth 80
fileNameRulerShape
Shape of the ruler drawn around file names in git show output. Set this to
ruler to use full width ruler lines instead of boxes. (Default: box)
git config --global diff-so-fancy.fileNameRulerShape ruler
shortHeaders
Simplify the header information to a single line for filename and line number. (Default false)
git config --global diff-so-fancy.shortHeaders true
semIntegration
Include the summary from sem in the header for each changed file. (Default false)
git config --global diff-so-fancy.semIntegration true
👨 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
- Delta
- Lazygit with diff-so-fancy integration
- difftastic
🏛️ License
MIT