diffr

mookidMIT更新放缓

用 Rust 写的终端 diff 高亮工具,在控制台里把代码差异渲染得更清楚,方便做代码审查和查看 git 变更。

Yet another diff highlighting tool

暂无版本620star26fork同步于 2026-11-07 07:32 UTC

怎么上手

从 README 代码块原样提取,可能是其中一种安装方式
git clone https://aur.archlinux.org/diffr.git
brew install diffr
cargo install diffr
硬件要求

README 没有说明硬件要求。

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

项目说明

这个项目的说明还在生成中,先参考下面「最近发版」和 README。

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

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

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

    README 原文

    未翻译

    diffr

    Reviewing changes involves reading diffs. Sometimes, a line-oriented presentation of changes is not precise enough, especially when changes involve long lines or very similar consecutive lines.

    This program processes such diffs, and outputs them (in the console) with additional diff information on top of the unified diff format, using text attributes.

    It works hunk by hunk, recomputing the diff on a word-by-word basis.

    The current implementation uses Myers' longest common subsequence algorithm.

    crates.io crates.io Build Status

    Demo Demo Demo

    Installation

    Arch Linux

    Install from the AUR:

    git clone https://aur.archlinux.org/diffr.git
    cd diffr
    makepkg -si
    
    Homebrew
    brew install diffr
    
    From source

    You will need the Rust compiler installed.

    To install the latest published version:

    cargo install diffr
    

    Alternatively, you can build the development version:

    git clone https://github.com/mookid/diffr.git
    cd diffr
    cargo install --path .
    

    How to use it?

    diffr tries to be a well behaved Unix program: it reads its input from stdin and writes to stdout.

    One-off usage
    git show HEAD | diffr
    
    Integration with git

    Add the following section to your .gitconfig file:

    [core]
        pager = diffr | less -R
    [interactive]
        diffFilter = diffr
    

    Alternatively, you can run from the command line:

    git config --global core.pager 'diffr | less -R'
    git config --global interactive.difffilter diffr
    
    Color customization

    Use the --colors flag.

    You can customize the display of diffing and common segments of added and removed lines.

    For example,

    diffr --colors refine-removed:background:200,0,0:foreground:white:bold
    

    tweaks the red used for uniquely removed text;

    The configuration used in the first screenshot is

    diffr --colors refine-added:none:background:0x33,0x99,0x33:bold --colors added:none:background:0x33,0x55,0x33 --colors refine-removed:none:background:0x99,0x33,0x33:bold --colors removed:none:background:0x55,0x33,0x33
    
    Display line numbers

    The --line-numbers displays the line numbers of the hunk.

    Related projects

    This is improvement on the diff-highlight script distributed with git.

    git itself provides both --word-diff and --color-words options to several commands.