diffnav: a git diff pager that highlights syntax

Git, the version control software, has git diff built-in to show you what's changed in your code - what lines were added, removed, or modified, across which files, and between which commits or branches. If you work with git, you may have used it. Maybe you've used it once and trid to forget it, because it works, but has a ... challenging user experience. It's visually noisy, monochrome, hard to scan, and in a large changeset you're paging through a wall of + and - hoping to find the file you care about.

git-delta fixes the first part. Syntax highlighting, line numbers, improved structure - delta transforms git diff output into something you can actually read. If you're not using it, you should be. It's the git equivalent of bat.

diffnav, by Dolev Hadar, takes the next step: it wraps delta with a file tree sidebar, giving you GitHub-style navigation in your terminal. You can now jump between changed files without losing your place, collapse directories, see diff stats at a glance, and toggle between side-by-side and unified views. Keyboard-driven, mouse-supported, and as simple as piping your diff through it:

git diff | diffnav
gh pr diff https://github.com/some/repo/pull/123 | diffnav

Or set it as your default pager and forget about it:

git config --global pager.diff diffnav

Very interesting tool to check out. It's also nicely done as a project; the github page for it has all the information you'd want from a project like this to give you an idea of if it'd be suitable for you or not.

Comments (0)

Sign in to comment

No comments yet.