This week's tip of the week is hunk.

You know the moment. You run git diff and get a wall of red and green text
with no real way to navigate it. It's fine for a two-line change. It's not
fine for anything bigger.

Hunk is a review-first terminal diff viewer that gives you a proper TUI. It
has a file sidebar for navigating multiple files, syntax highlighting, mouse
support, and keyboard navigation. It runs on macOS and Linux.

hunk as the git pager showing split mode vs stack mode depending on screen size

One thing I immediately appreciated: resize your terminal wide enough and it
automatically flips from stacked to side-by-side view. Run it with --watch
and the view auto-reloads as you make changes.

Install it with:

npm i -g hunkdiff

Note: the package name is hunkdiff but the binary is hunk.

Run hunk diff directly to get the full UI with file sidebar and menu bar:

hunk diff          # full UI with file sidebar and menu bar
hunk diff --staged
hunk diff --watch  # auto-reload as files change
hunk show          # review the latest commit

Optionally, add a git alias so you can type git d instead (what I do):

git config --global alias.d '!hunk diff'

Give hunk a go and let me know what you think.

That's it! Short and sweet. Until the next one!

Keep Reading