Skip to content

Commit

Permalink
Merge pull request #90 from arcticicestudio/feature/gh-61-diff-so-fan…
Browse files Browse the repository at this point in the history
…cy-without-git

Use "diff-so-fancy" without Git
  • Loading branch information
arcticicestudio authored Nov 29, 2017
2 parents d20e4d2 + b999307 commit 08cbbc4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions snowblocks/bash/bin/dsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Copyright (c) 2016-2017 Arctic Ice Studio <[email protected]>
# Copyright (c) 2016-2017 Sven Greb <[email protected]>

# Project: igloo
# Repository: https://github.com/arcticicestudio/igloo
# License: MIT

set -euo pipefail

# Allows to use "diff-so-fancy" to compare files that are not controlled by Git.
# Under the hood it makes use of "git diff" by using the "no-index" option which allows to compare the given two
# paths/files on the filesystem outside a working tree controlled by Git.
#
# @param $1 the path/files to compare
# @param $2 the path/files to be compared
# @see https://github.com/so-fancy/diff-so-fancy/issues/220#issuecomment-282530252
dsf() {
if [ "$#" -eq 2 ]; then
git diff --no-index --color "$@" | diff-so-fancy | less -RFXx2
fi
}

dsf $@

0 comments on commit 08cbbc4

Please sign in to comment.