diff-so-fancy

so-fancyMIT活跃维护

把 Git diff 输出重新排版成更易读的格式,突出改动位置和代码块,方便快速定位缺陷、提升代码审查效率。

Make your diffs human readable for improved code quality and faster defect detection. :tada:

v1.4.14发布于 2026-10-03 20:45 UTC18,112star +4 / 7 天350fork同步于 2026-11-10 11:24 UTC

怎么上手

由 README 提炼,执行前请确认
git config --global core.pager "diff-so-fancy | less --tabs=4 -RF"
git config --global interactive.diffFilter "diff-so-fancy --patch"
硬件要求按 README 说明

README 未说明,纯文本处理脚本,无特殊硬件要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把机器可读的 git diff 变成人眼易读的彩色输出,帮你更快发现代码缺陷

把 Git diff 输出重新排版成更易读的格式,突出改动位置和代码块,方便快速定位缺陷、提升代码审查效率。

核心能力

  • 重排 diff 输出,让改动更易读
  • 简化 hunk 头部为人类可读格式
  • 去掉每行开头的 + 和 - 符号
  • 用 Unicode 绘制分隔线,宽度可配置
  • 可作为 git 的 pager 和 interactive.diffFilter 使用

容易踩的坑

需先把 diff-so-fancy 脚本放进 $PATH,克隆仓库时 lib/ 目录必须与主脚本保持相对位置;通过 brew、npm、Fedora、Arch 等包管理器安装的版本问题需找对应打包仓库;多个行为由 git config 开关控制,默认值可能与预期不同

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.4.14
  1. v1.4.14最新正式版2026-10-03 · 2026-10-03 20:45 UTC

    New features

    • OSC 1717 diff-line metadata support for Lazygit — #538:
    • fileNameRulerShape option — #545, closes #522:
    • box (default) vs ruler shape for file names in git show mode.
    • Terminal now reads from env $COLUMNS before falling back to tput — #556:
    • --date iso 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.json repo URL
    • Bump actions/setup-node 4 -> 7 — #541.
  2. v1.4.122026-08-16 · 2026-08-16 17:07 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/so-fancy/diff-so-fancy/compare/v1.4.10...v1.4.12

  3. 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

  4. 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 --patch mode
    • Various README updates
    • add --shortHeaders as 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.pl to simplify color testing
    • Cleaner logic in get_diff_chunks() to make chunking smarter
    • High commit headers in git show mode

    New Contributors

    Full Changelog: https://github.com/so-fancy/diff-so-fancy/compare/v1.4.6...v1.4.8

  5. v1.4.62026-03-16 · 2026-03-16 18:03 UTC
    查看更新说明
    • d-s-f is much smarter and --patch mode should work in more (all?) scenarios
      • Added support for enabling patch mode via DSF_PATCH_MODE environment variable
    • Added a new CLI option --rulerWidth
    • Support ANSI reset without the 0. \e[0m vs \e[m
    • Upstream DiffHighlight.pm fixes. Allow "italic" in colors
    • Add some debug logging when started with --debug to help troubleshooting
    • Support git file copies better if diff.renames copies is enabled in .gitconfig
    • Better support for recursive diff like: diff -u -r /dir/a /dir/b

    What's Changed

    New Contributors

    Full Changelog: https://github.com/so-fancy/diff-so-fancy/compare/v1.4.4...v1.4.6

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    🎩 diff-so-fancy Circle CI build AppVeyor build

    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

    diff-highlight vs 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

    PersonRole
    @scottchiefbakerProject lead
    @OJFordBug triage
    @GenieTimTravis OSX fixes
    @AOSDebian packager
    @Stevemao/@Paul IrishNPM 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