https://github.com/z-shell/zsh-diff-so-fancy
⚙️ The diff-so-fancy for Zsh
https://github.com/z-shell/zsh-diff-so-fancy
awesome-zsh-plugins diff diff-utils git-diff git-difftool zsh zsh-plugin
Last synced: about 1 month ago
JSON representation
⚙️ The diff-so-fancy for Zsh
- Host: GitHub
- URL: https://github.com/z-shell/zsh-diff-so-fancy
- Owner: z-shell
- License: gpl-3.0
- Created: 2021-11-02T12:26:20.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-19T16:29:47.000Z (about 1 year ago)
- Last Synced: 2025-03-25T16:22:57.156Z (8 months ago)
- Topics: awesome-zsh-plugins, diff, diff-utils, git-diff, git-difftool, zsh, zsh-plugin
- Language: Shell
- Homepage: https://wiki.zshell.dev/ecosystem/plugins/diff-so-fancy
- Size: 3.75 MB
- Stars: 22
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: docs/README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-zsh-plugins - diff-so-fancy - Automatically installs [diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) and enables its use in ZSH and `git`. (Plugins / ZSH on Windows)
- fucking-awesome-zsh-plugins - diff-so-fancy - Automatically installs <b><code> 17857⭐</code></b> <b><code> 338🍴</code></b> [diff-so-fancy](https://github.com/so-fancy/diff-so-fancy)) and enables its use in ZSH and `git`. (Plugins / ZSH on Windows)
README
❮ Zi ❯ Plugin - zsh-diff-so-fancy

# zsh-diff-so-fancy
A simple plugin integrating [so-fancy/diff-so-fancy](https://github.com/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](https://github.com/so-fancy/diff-so-fancy#installation) or load it via your preferred method.
2. **Load the plugin** in your `.zshrc` or plugin manager:
```shell
# Example using Zi
zi ice as'program' pick'bin/*'
zi light z-shell/zsh-diff-so-fancy
```
3. **Use** the commands:
- `git dsf ` to see a diff rendered by diff-so-fancy
- `fancy-diff ` to compare two files with diff-so-fancy
## Customization
You can customize the `less` options by setting these environment variables in your `.zshrc` before loading the plugin:
```shell
# Customize less options for fancy-diff
export FANCY_DIFF_LESS_OPTS="--tabs=2 -RFX"
# Customize less options for git dsf
export GIT_DSF_LESS_OPTS="--tabs=2 -FRXS"
```
The default is `--tabs=4 -FRXSi` for both commands if not specified.
## Manual Configuration
```shell
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
```shell
# 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.
### Plugin Details
- Both `fancy-diff` and `git-dsf` use the `--patch` flag with `diff-so-fancy` to preserve the original diff format in the output, which is useful for interoperability with tools that parse diff output.
- The plugin follows the [Zsh Plugin Standard](https://wiki.zshell.dev/community/zsh_plugin_standard) and provides an unload function for plugin managers that support unloading.
- The plugin checks if `diff-so-fancy` is installed and provides a helpful warning if it's not found.
### Installation with [Zi](https://github.com/z-shell/zi)
```shell
zi ice as'null' sbin'bin/*'
zi light z-shell/zsh-diff-so-fancy
```
Or:
```shell
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**
```shell
zplug "z-shell/zsh-diff-so-fancy", as:command, use:"bin/"
```
- **Zgen**
```shell
zgen load z-shell/zsh-diff-so-fancy
```