#diff #code-review #git #console #cli

app diffr

An LCS based diff highlighting tool to ease code review from your terminal

5 releases

0.1.4 Mar 19, 2020
0.1.3 Dec 8, 2019
0.1.2 Sep 7, 2019
0.1.1 Jul 15, 2019
0.1.0 Jul 11, 2019

#739 in Command line utilities

Download history 38/week @ 2022-03-11 31/week @ 2022-03-18 18/week @ 2022-03-25 30/week @ 2022-04-01 41/week @ 2022-04-08 6/week @ 2022-04-15 22/week @ 2022-04-22 40/week @ 2022-04-29 57/week @ 2022-05-06 94/week @ 2022-05-13 72/week @ 2022-05-20 46/week @ 2022-05-27 59/week @ 2022-06-03 31/week @ 2022-06-10 14/week @ 2022-06-17 15/week @ 2022-06-24

131 downloads per month

MIT license

2.5K SLoC



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 output 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


Arch Linux

Install from the AUR:

git clone https://aur.archlinux.org/diffr.git
cd diffr
makepkg -si

From Source

You will need the Rust compiler installed.

To install the latest published version:

cargo install diffr

Alternatively, you can build the latest 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.

To test it:

cargo build --release
git show HEAD | path/to/diffr

To integrate it with git:

Add the following section to your .gitconfig file:

    log  = path/to/diffr | less -R
    show = path/to/diffr | less -R
    diff = path/to/diffr | less -R
    diffFilter = path/to/diffr

Display 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

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.


~19K SLoC