Top Related Projects
Quick Overview
diff-so-fancy is a command-line tool that enhances the output of Git diffs. It provides a more readable and visually appealing diff output, making it easier for developers to review changes in their Git repositories. The tool aims to improve the default Git diff experience with better formatting and highlighting.
Pros
- Improved readability with cleaner, more organized diff output
- Syntax highlighting for better visual distinction between changes
- Customizable options to tailor the output to personal preferences
- Easy integration with existing Git workflows
Cons
- Requires installation and configuration, which may be an extra step for some users
- May not be suitable for users who prefer the standard Git diff output
- Limited to command-line use, not integrated into GUI Git clients by default
- Some advanced Git diff features may not be fully supported
Getting Started
To install and use diff-so-fancy:
# Install via npm
npm install -g diff-so-fancy
# Or install via Homebrew on macOS
brew install diff-so-fancy
# Configure Git to use diff-so-fancy
git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
git config --global interactive.diffFilter "diff-so-fancy --patch"
# Use diff-so-fancy
git diff
After installation and configuration, diff-so-fancy will automatically enhance your Git diff output when you run git diff
or similar commands.
Competitor Comparisons
A syntax-highlighting pager for git, diff, grep, and blame output
Pros of delta
- Written in Rust, offering better performance and memory safety
- More customizable with themes and syntax highlighting options
- Supports side-by-side diff view
Cons of delta
- Requires installation of a binary, unlike diff-so-fancy which is a shell script
- May have a steeper learning curve due to more configuration options
- Potentially higher resource usage for simple diff tasks
Code comparison
delta:
let config = Config::from_env().unwrap_or_default();
let mut painter = Painter::new(&config);
painter.paint_lines(io::stdin().lock().lines());
diff-so-fancy:
#!/usr/bin/env bash
[ $# -ge 1 -a -f "$1" ] && input="$1" || input="-"
get_script_dir () {
src="${BASH_SOURCE[0]}"
Both projects aim to enhance Git's diff output, but delta offers more features and customization at the cost of slightly higher complexity. diff-so-fancy is simpler to set up and use, making it a good choice for users who want a quick improvement to their diff output without additional configuration. delta is better suited for users who desire more control over their diff appearance and are willing to invest time in customization.
simple terminal UI for git commands
Pros of lazygit
- Full-featured terminal UI for Git operations
- Interactive staging, committing, and branch management
- Customizable keybindings and color schemes
Cons of lazygit
- Steeper learning curve due to more complex interface
- Requires installation and setup, not a simple script
- May be overkill for users who only need diff highlighting
Code comparison
diff-so-fancy:
git diff | diff-so-fancy
lazygit:
lazygit
# Opens interactive terminal UI
Summary
diff-so-fancy is a focused tool that enhances Git diff output with improved highlighting and readability. It's lightweight and easy to use as a simple command-line utility.
lazygit, on the other hand, is a comprehensive Git terminal UI that offers a wide range of Git operations in an interactive interface. It provides more functionality but requires more setup and learning.
Choose diff-so-fancy for quick, enhanced diff views, or lazygit for a full-featured Git management experience in the terminal.
Text-mode interface for git
Pros of tig
- More comprehensive Git repository browser with multiple views (log, diff, blame, etc.)
- Interactive interface allowing navigation and exploration of Git history
- Customizable key bindings and color schemes for personalized experience
Cons of tig
- Steeper learning curve due to more complex interface and features
- Requires terminal-based interaction, which may not suit all users
- Less focus on enhancing diff readability compared to diff-so-fancy
Code comparison
tig usage:
tig
tig status
tig show
diff-so-fancy usage:
git diff | diff-so-fancy
git show HEAD | diff-so-fancy
Summary
tig is a feature-rich Git repository browser offering multiple views and interactive exploration of Git history. It provides a comprehensive toolset for navigating and analyzing Git repositories but requires more time to master. diff-so-fancy, on the other hand, focuses specifically on enhancing the readability of Git diffs with improved highlighting and formatting. While tig offers a broader range of functionality, diff-so-fancy excels in its specific purpose of making diffs more visually appealing and easier to understand.
GitHub’s official command line tool
Pros of cli
- Offers a comprehensive GitHub CLI tool with a wide range of features
- Provides seamless integration with GitHub workflows and actions
- Supports multiple platforms (Windows, macOS, Linux)
Cons of cli
- Larger installation size and potentially more complex setup
- May have a steeper learning curve for users new to command-line interfaces
- Focuses on GitHub-specific functionality, less useful for general Git operations
Code comparison
diff-so-fancy:
git diff --color | diff-so-fancy
cli:
gh pr create --title "New feature" --body "Description of changes"
gh issue list --label bug --limit 10
gh repo clone owner/repo
Summary
diff-so-fancy is a focused tool for enhancing Git diff output, making it more readable and visually appealing. It's lightweight and easy to integrate into existing Git workflows.
cli, on the other hand, is a full-featured GitHub CLI tool that provides a wide range of functionality for interacting with GitHub repositories, issues, pull requests, and more. It's more comprehensive but also more complex and GitHub-specific.
While diff-so-fancy excels at improving diff readability, cli offers a broader set of features for managing GitHub projects from the command line. The choice between the two depends on whether you need a simple diff enhancement tool or a complete GitHub CLI solution.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
diff-so-fancy
diff-so-fancy
strives to make your diffs human readable instead of machine readable. This helps improve code quality and helps you spot defects faster.
Screenshot
Vanilla git diff
vs git
and diff-so-fancy
Install
Simply copy the diff-so-fancy
script from the latest release into your $PATH
and you're done. Alternately to test development features you can clone this repo and then put the diff-so-fancy
script (symlink will work) into your $PATH
. The lib/
directory will need to be kept relative to the core script.
If you are using a ZSH framework like zgenom or oh-my-zsh, refer to Zsh plugin support for diff-so-fancy for detailed installation instructions.
diff-so-fancy
is also available from the NPM registry, brew, as a package on Nix, Fedora, in the Arch extra repo, and as ppa:aos for Debian/Ubuntu Linux.
Issues relating to packaging ('installation does not work', 'version is out of date', etc.) should be directed to those packages' own repositories/issue trackers where applicable. Issues relating to packaging ("installation does not work", "version is out of date", etc.) should be directed to those packages' repositories/issue trackers where applicable.
Note: Windows users may need to install MinGW or the Windows subsystem for Linux.
Usage
With git
Configure git to use diff-so-fancy
for all diff output:
git config --global core.pager "diff-so-fancy | less --tabs=4 -RF"
git config --global interactive.diffFilter "diff-so-fancy --patch"
Improved colors for the highlighted bits
The default Git colors are not optimal. The colors used for the screenshot above were:
git config --global color.ui true
git config --global color.diff-highlight.oldNormal "red bold"
git config --global color.diff-highlight.oldHighlight "red bold 52"
git config --global color.diff-highlight.newNormal "green bold"
git config --global color.diff-highlight.newHighlight "green bold 22"
git config --global color.diff.meta "11"
git config --global color.diff.frag "magenta bold"
git config --global color.diff.func "146 bold"
git config --global color.diff.commit "yellow bold"
git config --global color.diff.old "red bold"
git config --global color.diff.new "green bold"
git config --global color.diff.whitespace "red reverse"
With diff
Use -u
with diff
for unified output, and pipe the output to diff-so-fancy
:
diff -u file_a file_b | diff-so-fancy
It also supports the recursive mode of diff with -r
or --recursive
as first argument
diff -r -u folder_a folder_b | diff-so-fancy
diff --recursive -u folder_a folder_b | diff-so-fancy
Options
markEmptyLines
Should the first block of an empty line be colored. (Default: true)
git config --bool --global diff-so-fancy.markEmptyLines false
changeHunkIndicators
Simplify git header chunks to a more human readable format. (Default: true)
git config --bool --global diff-so-fancy.changeHunkIndicators false
stripLeadingSymbols
Should the pesky +
or -
at line-start be removed. (Default: true)
git config --bool --global diff-so-fancy.stripLeadingSymbols false
useUnicodeRuler
By default, the separator for the file header uses Unicode line-drawing characters. If this is causing output errors on your terminal, set this to false
to use ASCII characters instead. (Default: true)
git config --bool --global diff-so-fancy.useUnicodeRuler false
rulerWidth
By default, the separator for the file header spans the full width of the terminal. Use this setting to set the width of the file header manually.
git config --global diff-so-fancy.rulerWidth 80
The diff-so-fancy team
Person | Role |
---|---|
@scottchiefbaker | Project lead |
@OJFord | Bug triage |
@GenieTim | Travis OSX fixes |
@AOS | Debian packager |
@Stevemao/@Paul Irish | NPM release team |
Contributing
Pull requests are quite welcome, and should target the next
branch. We are also looking for any feedback or ideas on how to make diff-so-fancy
even fancier.
Other documentation
Alternatives
- Delta
- Lazygit with diff-so-fancy integration
License
MIT
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot