Skills2026年4月15日·1 分钟阅读

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.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
diff-so-fancy guide
直接安装命令
npx -y tokrepo@latest install 43fc75b0-38c4-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

TL;DR
Drop-in replacement for git diff that strips noise, highlights word-level changes, and produces clean readable output.
§01

What it is

diff-so-fancy is a command-line tool that transforms ugly unified diffs into clean, human-readable output. It strips redundant filename headers, removes leading +/- characters, and highlights word-level changes within each line. The result looks like a GitHub-style diff in your terminal.

The tool targets any developer who reads diffs in the terminal. It works as a drop-in replacement for git's default diff pager with zero learning curve.

§02

How it saves time or tokens

Reading standard unified diffs requires mental effort to parse +/- prefixes, track which file you are in, and spot the actual changed words within long lines. diff-so-fancy eliminates this overhead by highlighting only what changed at the word level. Reviewing pull requests and debugging commits becomes faster.

§03

How to use

  1. Install diff-so-fancy via npm, brew, or your package manager.
  2. Configure git to use it as the default pager.
  3. Run git diff as usual — the output is automatically formatted.
# Install
npm install -g diff-so-fancy
# or
brew install diff-so-fancy

# Configure git to use diff-so-fancy
git config --global core.pager 'diff-so-fancy | less --tabs=4 -RFX'
git config --global interactive.diffFilter 'diff-so-fancy --patch'

# Now just use git diff normally
git diff
git log -p
git show HEAD
§04

Example

# Standard git diff (hard to read):
- const MAX_RETRIES = 3;
+ const MAX_RETRIES = 5;

# diff-so-fancy output (word-level highlight):
# The line shows 'MAX_RETRIES = ' in normal color,
# '3' highlighted in red, '5' highlighted in green.
# No +/- prefixes. Clean file headers.
§05

Related on TokRepo

§06

Common pitfalls

  • diff-so-fancy does not work well with git add -p (interactive staging) unless you also set interactive.diffFilter; without it, the patch mode shows raw diffs.
  • Some terminal color schemes make the highlights hard to see; adjust diff-so-fancy's color settings or switch to a dark terminal theme.
  • Piping diff-so-fancy output to other tools strips the ANSI colors; use --color=always if you need to pipe through grep or less.

常见问题

Does diff-so-fancy work with all git commands?+

Yes. Once configured as the default pager, diff-so-fancy processes output from git diff, git log -p, git show, git stash show, and any command that produces diff output. It also works with plain diff commands outside of git.

Can I use diff-so-fancy alongside delta or bat?+

They serve similar purposes. delta is an alternative diff highlighter with syntax-aware highlighting. You typically choose one as your git pager. If you prefer delta's features, use delta. diff-so-fancy is simpler and requires less configuration.

How do I install diff-so-fancy without npm?+

diff-so-fancy is available through Homebrew (brew install diff-so-fancy), apt (on Debian/Ubuntu), and as a standalone Perl script you can download directly. It has minimal dependencies — just Perl, which is pre-installed on most Unix systems.

Does diff-so-fancy change the actual diff content?+

No. diff-so-fancy only changes the visual presentation. The underlying diff data is identical. It strips visual noise like +/- prefixes and redundant headers but does not alter which lines are shown as added, removed, or changed.

Can I customize the colors?+

Yes. diff-so-fancy respects git config color settings. You can configure colors for added lines, removed lines, changed words, and section headers through standard git config commands. The README documents all available color options.

引用来源 (3)
  • diff-so-fancy GitHub— diff-so-fancy strips noise and highlights word-level changes in diffs
  • Git Documentation— Git pager configuration for custom diff output
  • GitHub Docs— Improving code review effectiveness through better diff visualization

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产