Configs2026年4月11日·1 分钟阅读

delta — Syntax-Highlighting Pager for Git Diff and Grep

delta is a syntax-highlighting pager for git, diff, grep, and rg output. Beautiful side-by-side diffs with language-aware highlighting, line numbers, and theming. Drop-in replacement for the default git pager.

AI
AI Open Source · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

# Install
brew install git-delta                     # macOS
cargo install git-delta                    # Rust
sudo apt install git-delta                 # Debian 13+

Configure git to use delta (~/.gitconfig):

[core]
    pager = delta

[interactive]
    diffFilter = delta --color-only

[delta]
    navigate = true
    light = false
    side-by-side = true
    line-numbers = true
    syntax-theme = Dracula

[merge]
    conflictstyle = diff3

[diff]
    colorMoved = default

Use with other tools:

git diff                              # Uses delta automatically
git show HEAD                         # Uses delta
rg --json pattern | delta             # Colorized ripgrep output
diff -u a.txt b.txt | delta           # Generic diff
介绍

delta is a syntax-highlighting pager for git, diff, and grep output. Written in Rust by Dan Davison. Drop-in replacement for the default git pager that transforms ordinary diff output into beautiful side-by-side views with syntax highlighting, line numbers, and language-aware theming.

What delta Does

  • Syntax highlighting — 100+ languages via syntect
  • Side-by-side view — optional two-column mode
  • Line numbers — in diffs
  • File headers — stylized, navigable
  • Navigation — jump between files with n / N
  • Themes — Sublime Text themes work
  • Merge conflicts — 3-way diff highlight
  • Whitespace errors — visible
  • git blame — also prettified
  • Works with — git, diff, rg, blame

Architecture

Rust binary that reads diff/patch format on stdin and writes colorized output to stdout. Integrates with git via core.pager = delta. Syntax highlighting uses the syntect crate (Sublime .sublime-syntax compatible).

Self-Hosting

CLI tool, git pager.

Key Features

  • Syntax highlighting for 100+ languages
  • Side-by-side diff view
  • Line numbers
  • File navigation (n/N)
  • Sublime theme compatibility
  • Works with git diff/show/log/blame
  • Integrates with rg, grep
  • Dark and light modes
  • Configurable via gitconfig

Comparison

Pager Highlighting Side-by-side Language
delta Yes Yes Rust
diff-so-fancy Yes No Perl
diff-highlight (git) Limited No Perl
bat + diff Yes No Rust
less No No C

常见问题 FAQ

Q: 和 diff-so-fancy? A: 功能类似。delta 速度更快(Rust)、支持 side-by-side、语法高亮更丰富。diff-so-fancy 更老牌、更简单。

Q: side-by-side 看不清? A: 调整 max-line-length 和终端宽度。超宽的行会自动换行,窄终端建议关 side-by-side。

Q: git log 也能用? A: 能。git log -p 会自动走 delta 的 pager。git blame 也有独立高亮。

来源与致谢 Sources

讨论

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

相关资产