Skip to content

dlvhdr/diffnav

Repository files navigation

diffnav

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

Caution

This is early in development, bugs are to be expected.

Feel free to open issues.

Demo

Installation

Homebrew:

brew install dlvhdr/formulae/diffnav

Go:

go install github.com/dlvhdr/diffnav@latest

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

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 diffs
  hideHeader: 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
Option Type Default Description
ui.hideHeader bool false Hide the "DIFFNAV" header
ui.hideFooter bool false Hide the footer with keybindings help
ui.showFileTree bool true Show file tree on startup
ui.fileTreeWidth int 26 Width of the file tree sidebar
ui.searchTreeWidth int 50 Width of the search panel

Delta

You can also configure the diff rendering through delta. Check out their docs.

If you want the exact delta configuration I'm using - it can be found here.

Keys

Key Description
j Next file
k Previous file
Ctrl-d Scroll the diff down
Ctrl-u Scroll the diff up
e Toggle the file tree
t Search/go-to file
y Copy file path
q Quit

Under the hood

diffnav uses:

Screenshots use:

About

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

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •