diff-so-fancy README

The project's README from github.com/so-fancy/diff-so-fancy. As one markdown file: README.md.

🎩 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

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

🏛️ License

MIT

diff-so-fancy (so-fancy/diff-so-fancy)

Searching Database…

这是干什么的?一个命令行工具,能把 git 那种机器格式的 diff 输出变成人类易读的文本,让你更快地审查改动、发现问题。
这是要添加到我项目里的库,还是一个需要安装的工具?是一个独立工具。你只需安装一个脚本,然后要么配置 git 让每次 diff 都自动运行它,要么在终端里把任何 diff 输出通过管道传给它。
怎么安装,怎么接入 git?把最新 GitHub release 里的 diff-so-fancy 脚本复制到你的 $PATH 中,或者直接装包:它发布在 npm、Homebrew、Fedora、Arch 的 extra 仓库里,Debian/Ubuntu 上还有 ppa:aos。然后配置 git,让所有 diff 输出都使用它。
除了 git,运行它还需要别的东西吗?它是用 Perl 写的,所以你的机器上需要有 Perl 运行环境,另外日常的 diff 流程也离不开 git。
安装时有什么坑吗?如果你是为了开发而克隆仓库(而不是用 release 版本),lib/ 目录必须和主脚本放在同一目录下。npm 或发行版包的问题应该反馈到对应包自己的 issue 跟踪器,而不是这个仓库。
它能在 Windows 上运行吗,还是只能用于 Mac 和 Linux?它是一个可移植的脚本,只要能跑 Perl 和 git 的地方就能用:README 里列出了 macOS 的 brew、Fedora、Arch 以及 Debian/Ubuntu 的 PPA,而且 npm 包是跨平台的,Windows 也能用。
它具体把 diff 的显示改成了什么样?git 的代码块(chunk)头部会变成简化、易读的格式,开头第一段空行会加上颜色,行首的 + 和 - 符号也可以去掉。头部可以精简成只有文件名和行号的一行,还会根据你的屏幕大小画一把 Unicode 标尺。这些都是可选项 —— markEmptyLines、changeHunkIndicators、stripLeadingSymbols、useUnicodeRuler、rulerWidth、shortHeaders、semIntegration —— 每项都有合理的默认值。
我能在 git 之外用它处理普通的 diff 输出吗?可以 —— 用 -u 参数运行 diff 得到统一格式的输出,然后通过管道传给 diff-so-fancy。也支持递归模式,用 -r 或 --recursive 即可。
它和 Delta 或 difftastic 有什么不同?README 把 Delta、difftastic 和 Lazygit 列为同类工具。Lazygit 甚至内置了 diff-so-fancy 集成,所以你可以直接在这个终端界面里获得同样易读的输出,不用在两者之间做选择。
Creator
so-fancy
Size
0.8 MB
Stars
18.1K
Age
10y
Commits · 90 Days