Code Monkey home page Code Monkey logo

diff-so-fancy's Introduction

diff-so-fancy Circle CI build TravisCI build AppVeyor build

diff-so-fancy builds on the good-lookin' output of git contrib's diff-highlight to upgrade your diffs' appearances.

  • Output will not be in standard patch format, but will be readable.
  • No pesky + or - at line-start, making for easier copy-paste.

Screenshot

git diff vs git diff --color | diff-so-fancy

diff-highlight vs diff-so-fancy

Usage

You can do one-off fanciness:

git diff --color | diff-so-fancy

But, you'll probably want to fancify all your diffs. Run this so git diff (and git show) will use it:

git config --global pager.diff "diff-so-fancy | less --tabs=1,5 -RFX"
git config --global pager.show "diff-so-fancy | less --tabs=1,5 -RFX"

However, if you'd prefer to do the fanciness on-demand with git dsf, drop an alias in your ~/.gitconfig:

dsf = "!git diff --color $@ | diff-so-fancy"

Install

For convenience, the recommended installation is via NPM. If you'd prefer, you may choose to do a manual installation instead.

npm install -g diff-so-fancy

This will install and link the diff-so-fancy and diff-highlight scripts.

On Mac, you can install via Homebrew:

brew update
brew install diff-so-fancy

Improved colors for the highlighted bits

diff-highlight has default colors that are arguably a little nasty. They'll work fine, but you can try some fancier colors:

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"

You may also want to configure general diff colors.

Manual install

If you want, you can choose to install manually:

  1. Grab the two scripts (diff-highlight and diff-so-fancy) via either downloading or cloning the repo.
  2. If you download diff-highlight from the official git repo, give it a chmod +x.
  3. Place them in a location that is in your PATH directly or with symlinks.
  4. Set up the git pager.diff and pager.show configs, as described above.

Note: The diff-highlight dependency is an official git-contrib script, duplicated here for convenience. If you prefer less fancy in your diff, you also use diff-highlight on it's own.

Opting-out

Sometimes you will want to bypass diff-so-fancy. Use --no-pager for that:

git --no-pager diff

History

diff-so-fancy started as a commit in paulirish's dotfiles, which grew into a standalone script. Later, @stevemao brought it into its own repo (here), and gave it the room to mature. It's quickly grown into a widely collaborative project.

Contributing

Pull requests quite welcome, along with any feedback or ideas.

Hacking

# fork and clone the diff-so-fancy repo.
git clone https://github.com/so-fancy/diff-so-fancy/ && cd diff-so-fancy

# test a saved diff against your local version
cat test/fixtures/ls-function.diff  | ./diff-so-fancy

# setup symlinks to use local copy
npm link
cd ~/projects/catfabulator && git diff

Running tests

You'll need to install bats, the Bash automated testing system. It's also available as brew install bats

git submodule update --init  # pull in the assertion library, bats-assert

# Run the test suite once:
bats test

# Run it on every change with `entr`
brew install entr
ls --color=never diff-so-fancy test/*.bats | entr bats test

Be sure to lint your scripts via shellcheck

brew install shellcheck
shellcheck diff-so-fancy update-deps.sh

License

MIT

diff-so-fancy's People

Contributors

anshul avatar arthurdarcet avatar aziz avatar bdossantos avatar cht8687 avatar djui avatar james2doyle avatar loklaan avatar noscript avatar ojford avatar pauley-unsaturated avatar paulirish avatar stevemao avatar tnguyen14 avatar tommarshall avatar webflo avatar xixixao avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.