-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…cy-without-git Use "diff-so-fancy" without Git
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 $@ |