← 返回命令列表

Linux command

delta 命令

文本

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

View git diff

git diff | delta

Compare two files

delta [file1.txt] [file2.txt]

Use side-by-side

delta -s [file1.txt] [file2.txt]

Show line numbers

delta -n [file1.txt] [file2.txt]

Use specific syntax

delta --syntax-theme [Dracula] [file1.txt] [file2.txt]

View git log

git log -p | delta

Show diff with navigate

git diff | delta --navigate

Configure as git pager

git config --global core.pager delta

List available syntax

delta --list-syntax-themes

说明

delta is a syntax-highlighting pager for git, diff, and grep output. It provides beautiful, readable diffs with features like side-by-side view, line numbering, and word-level change highlighting. delta is designed as a git pager replacement, integrating seamlessly with git diff, git show, git log, and git blame. It uses the same syntax highlighting engine as bat, supporting hundreds of languages. Features include navigation between hunks, customizable themes, hyperlinks to line numbers, and special handling of merge conflicts. It can also process unified diff output from other tools.

参数

-s, --side-by-side
Side-by-side display mode.
-n, --line-numbers
Show line numbers.
--syntax-theme _THEME_
Syntax highlighting theme.
--word-diff-regex _REGEX_
Highlight word-level changes using regex to define words.
--hyperlinks
Render commit hashes, file paths, and line numbers as terminal hyperlinks.
--color-only
Do not alter formatting; only add syntax highlighting.
--diff-stat-align-width _N_
Width allocated for file paths in a diff stat section.
--features _NAMES_
Activate named feature sets defined in gitconfig.
--list-syntax-themes
List available syntax-highlighting themes.
--paging _auto|always|never_
Control pager usage.
--true-color _auto|always|never_
Control 24-bit RGB color output.
--navigate
Enable navigation with n/N keys.
--dark/--light
Optimize for dark/light terminal.
--diff-so-fancy
Emulate diff-so-fancy output.
--raw
Do not alter the input in any way; only highlight syntax.
--width _N_
The width of underline/overline decorations and side-by-side mode.
--tabs _N_
Number of spaces to replace tab characters with (default: 4).
--help
Display help information.

FAQ

What is the delta command used for?

delta is a syntax-highlighting pager for git, diff, and grep output. It provides beautiful, readable diffs with features like side-by-side view, line numbering, and word-level change highlighting. delta is designed as a git pager replacement, integrating seamlessly with git diff, git show, git log, and git blame. It uses the same syntax highlighting engine as bat, supporting hundreds of languages. Features include navigation between hunks, customizable themes, hyperlinks to line numbers, and special handling of merge conflicts. It can also process unified diff output from other tools.

How do I run a basic delta example?

Run `git diff | delta` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -s, --side-by-side do in delta?

Side-by-side display mode.