Skip to content

z-shell/zsh-diff-so-fancy

Repository files navigation

Logo ❮ Zi ❯ Plugin - zsh-diff-so-fancy

zsh-diff-so-fancy


zsh-diff-so-fancy

A simple plugin integrating so-fancy/diff-so-fancy into Zsh. It provides:

  • git dsf: A subcommand to run Git diffs through diff-so-fancy
  • fancy-diff: A helper to run a unified diff and beautify it with diff-so-fancy

Quick Start

  1. Install diff-so-fancy or load it via your preferred method.
  2. Load the plugin in your .zshrc or plugin manager:
    # Example using Zi
    zi ice as'program' pick'bin/*'
    zi light z-shell/zsh-diff-so-fancy
  3. Use the commands:
    • git dsf <files> to see a diff rendered by diff-so-fancy
    • fancy-diff <file1> <file2> to compare two files with diff-so-fancy

Manual Configuration

diff-so-fancy --colors        # Show recommended color config
diff-so-fancy --set-defaults  # Configure Git to use diff-so-fancy with suggested colors
diff-so-fancy --patch         # Patch mode, interoperable with `git add --patch`

Git Integration

# Use diff-so-fancy for all diffs
git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"

# Use diff-so-fancy for `git add --patch`
git config --global interactive.diffFilter "diff-so-fancy --patch"

diff-so-fancy Options

  • markEmptyLines (bool, default: true) Color the first block of an empty line.
  • changeHunkIndicators (bool, default: true) Simplify Git header chunks to a more readable format.
  • stripLeadingSymbols (bool, default: true) Remove leading + or - from lines.
  • useUnicodeRuler (bool, default: true) Use Unicode line-drawing characters for file headers (disable if your terminal cannot display them).
  • rulerWidth (int, default: full width) Set a fixed width for the file header separator.

Installation with Zi

zi ice as'null' sbin'bin/*'
zi light z-shell/zsh-diff-so-fancy

Or:

zi ice as'program' pick'bin/*'
zi light z-shell/zsh-diff-so-fancy

This places diff-so-fancy, fancy-diff, and git-dsf in $PATH, adding the dsf subcommand to Git automatically.

Other Plugin Managers

  • Zplug
    zplug "z-shell/zsh-diff-so-fancy", as:command, use:"bin/"
  • Zgen
    zgen load z-shell/zsh-diff-so-fancy