Skip to content

Repository files navigation


output-onlinepngtools

A git diff pager based on delta but with a file tree, à la GitHub.

Latest ReleaseDiscord

❤️ Sponsoring

If you enjoy diffnav and want to help, consider supporting the project with a donation at the sponsors page.

Sponsors

TUI Visionary

ArchitectPeter Steinberger

TUI Power User

Alexander GarberBrend SmitsBrian GianforcarocdxnKen SandersLuke RollansMatthew ChisolmNikolay KolevPhilippe SerhalScott AmessideshowbarkerSpencer JuddStefan LüdinStevie HuhUlrich DangelvosahlojWill Cory

TUI Backer

Jeff Wainwrightpurajit

Installation

Homebrew:

brew install diffnav

or from my tap directly:

brew install dlvhdr/formulae/diffnav

Go:

git clone https://github.com/dlvhdr/diffnav.git
cd diffnav
go install .

Note

To get the icons to render properly you should download and install a Nerd font from https://www.nerdfonts.com/. Then, select that font as your font for the terminal.

You can install these with brew as well: brew install --cask font-<FONT NAME>-nerd-font

Usage

Pipe into diffnav

  • git diff | diffnav
  • gh pr diff https://github.com/dlvhdr/gh-dash/pull/447 | diffnav

Set up as Global Git Diff Pager

git config --global pager.diff diffnav

Flags

FlagDescription
--side-by-side, -sForce side-by-side diff view
--unified, -uForce unified diff view
--watch, -wWatch mode: periodically re-run a command and refresh
--watch-cmdCommand to run in watch mode (implies --watch, default: git diff)
--watch-intervalInterval between watch refreshes (default: 2s)

Example:

git diff | diffnav --unified
git diff | diffnav -u

Watch Mode

Watch mode lets diffnav periodically re-run a diff command and refresh the display automatically. This is useful for monitoring changes as you work.

# watch unstaged changes (default: git diff, every 2s)
diffnav --watch
# watch staged changes with a custom interval
diffnav --watch-cmd "git diff --cached" --watch-interval 5s
# watch changes against a specific branch
diffnav --watch-cmd "git diff main..."

Configuration

The config file is searched in this order:

  1. $DIFFNAV_CONFIG_DIR/config.yml (if env var is set)
  2. $XDG_CONFIG_HOME/diffnav/config.yml (if set, macOS only)
  3. ~/.config/diffnav/config.yml (macOS and Linux)
  4. OS-specific config directory (e.g., ~/Library/Application Support/diffnav/config.yml on macOS)

Example config file:

ui:
# Hide the header to get more screen space for diffshideHeader: true# Hide the footer (keybindings help)hideFooter: true# Start with the file tree hidden (toggle with 'e')showFileTree: false# Customize the file tree width (default: 26)fileTreeWidth: 30# Customize the search panel width (default: 50)searchTreeWidth: 60# Icon style: "status" (default), "simple", "filetype", "full", "unicode", or "ascii"icons: nerd-fonts-status# Color filenames by git status (default: true)colorFileNames: false# Show the amount of lines added / removed next to the fileshowDiffStats: false# Use side-by-side diff view (default: true, set false for unified)sideBySide: true# How many levels of folders to open on start (-1 = all, 0 = none, 1 = first level, etc.)startFoldersOpenDepth: 1# The ID of the theme to use. Press `T` to see available themes - IDs areshown below each theme name. (default: tokyo_night)theme: gruvbox_dark
OptionTypeDefaultDescription
ui.hideHeaderboolfalseHide the "DIFFNAV" header
ui.hideFooterboolfalseHide the footer with keybindings help
ui.showFileTreebooltrueShow file tree on startup
ui.fileTreeWidthint26Width of the file tree sidebar
ui.searchTreeWidthint50Width of the search panel
ui.iconsstringnerd-fonts-statusIcon style (see below for details)
ui.colorFileNamesbooltrueColor filenames by git status
ui.showDiffStatsbooltrueShow the amount of lines added / removed next to the file
ui.sideBySidebooltrueUse side-by-side diff view (false for unified)
ui.startFoldersOpenDepthint-1Folder open depth on start (-1 = all, 0 = none)
ui.themestringtokyo_nightThe ID of the theme to use

Icon Styles

StyleDescription
nerd-fonts-statusBoxed git status icons colored by change type
nerd-fonts-simpleGeneric file icon colored by change type
nerd-fonts-filetypeFile-type specific icons (language icons) colored by change type
nerd-fonts-fullBoth status icon and file-type icon, all colored
unicodeUnicode symbols (+/⛌/●)
asciiPlain ASCII characters (+/x/*)

Keys

KeyDescription
jNext node
kPrevious node
nNext file
p / NPrevious file
Ctrl-dScroll the diff half page down
Ctrl-uScroll the diff half page up
Ctrl-eScroll the diff one line down
Ctrl-yScroll the diff one line up
eToggle the file tree
tSearch/go-to file
yCopy file path
iCycle icon style
oOpen file in $EDITOR
sToggle side-by-side/unified view
TabSwitch focus between the panes
TOpen the theme picker
qQuit

Discord

Have questions? Join our Discord community!

Contributing

See the contribution guide at https://www.gh-dash.dev/contributing.

Under the Hood

diffnav uses:

Screenshots use:

About

A git diff pager based on delta but with a file tree, à la GitHub.

Topics

Resources

Contributing

Stars

1.5k stars

Watchers

6 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages