so-fancy / diff-so-fancy Goto Github PK
View Code? Open in Web Editor NEWGood-lookin' diffs. Actually… nah… The best-lookin' diffs. :tada:
License: MIT License
Good-lookin' diffs. Actually… nah… The best-lookin' diffs. :tada:
License: MIT License
Repo more than meets the star/fork requirements. Most Mac users would probably prefer a pure-brew install than a brew+npm install.
brew install gnu-sed --with-default-names && npm install -g diff-so-fancy
would become brew install diff-so-fancy
. You could even include the git config
uration in the formula.
I think it's time for us to add proper unit tests.
I haven't seen a test suite for a project like this before, but it shouldnt be too bad. I'm thinking a folder of input text files, with ANSI escapes and all. And a folder of expected output. Seem right?
Is there a test runner that'd work well for us?
Here's a view of trailing space highlighting kinda breaking with diff-so-fancy:
Original output:
�[1;31m- dir="$(cd -P "$( dirname "$src" )" && pwd)"�[m
�[1;32m+�[m�[1;32m dir="$(cd -P "$( dirname "$src" )" && pwd)"�[m�[7;31m �[m
src="$(readlink "$src")"�[m
�[1;31m- [[ $src != /* ]] && src="$dir/$src"�[m
�[1;32m+�[m�[1;32m [[ $src != /* ]] && src="$dir/$src"�[m�[7;31m �[m
When text is added/removed in a line, why not just show the added/removed part instead of a removed original line and a new line?
In the interest of saving screen real-estate, can we remove deleted file mode
. I can maybe understand showing the added file mode, but who cares about what the file mode was when it was deleted.
Should we remove this line? Or am I just complaining about nothing.
new file mode 100644
────────────────────────────────────────────────────────────────
added: hello.txt
────────────────────────────────────────────────────────────────
@@ -0,0 +1 @@
HI THERE
deleted file mode 100644
────────────────────────────────────────────────────────────────
deleted: package.json
────────────────────────────────────────────────────────────────
@@ -1,29 +0,0 @@
I've set up the tool using the instructions from the README (npm install, then set core.pager value). I've run a test diff and the first code line of each file is incorrectly highlighted and colored:
Also, the headers are white instead of yellow, but that's a minor issue.
My environment: Windows 10, Cmder console (but issue also occurs in PowerShell), default Git for Windows installer.
Currently, it only sets the colour of particular lines. If the terminal has red or green text for example, it's impossible to tell which lines have been removed or added respectively. If the colour of "normal" text, which hasn't changed, is defaulted to black or white, then it would be much easier to see the changes.
Not sure if this is even fixable since you're piping the output but it would be nice :)
git config --global core.pager "diff-so-fancy | less --tabs=1,5 -R"
This highjacks things like git log
, and other commands locally for me. Is there a non-destructive way of doing this? If not, I'd suggest showing how to alias it in bash instead of adding it to the gitconfig.
we've moved this repo!
There's been a few changes that aren't reflected in the screenshot or summarized in the readme's text.
e.g. the header_clean, code is flush left, dim foreground on context line
Anybody wanna take a swipe at updating those?
When I try git diff --color | diff-so-fancy
I get the following error: sed: 1: "/^((\x1B\[([0-9]{1,3}(; ...": bad flag in substitute command: '}'
.
I've just installed it globally and tried a diff.
When double clicking the filename the a/
or b/
is copied along. It would be great to remove that, or separate it with a space, or add the plain filename as a separate line as well, to be able to support this use case.
Wow, after using git diff
in the CLI for so long I must say I really enjoy this stuff !
One thing though that still prevents me from using it when investing large commits (and therefore using it as an alias in my git config), it seems that I can't use the arrows and space key to scroll up and down in the output provided... It just prints everything out and stops. I liked the less
-like behavior of plein ol' git diff
, am I missing something or is this just not the way it works ?
Any plan on supporting this or is there a technical limitation of some sort ?
diff-ss is the side-by-side diff version of git diff. It would be nice to join both (all three together with diff-highlight
) to make the ultimate terminal diffing experience! 😎
Disclaimer: of course this is a shameless plug from the author...
Maybe we should just depend on diff-highlight
from inside of diff-so-fancy
.
That would mean people instead configure it with git diff | diff-so-fancy
directly.
If diff-highlight
isn't found, we could just pass through the stdin
and perhaps issue a warning that says "hey you're missing diff-highlight bud"
Seems a little more user-friendly. wdyt?
I added the colors for diff-highlight
in my .gitconfig
as instructed, however the output of git diff | diff-highlight
does not output any colors.
Could there be something that I am missing here?
I'm getting this error when I try diff-so-fancy:
sed: 1: "/^((\033\[([0-9]{1,3}(;[0- ...": bad flag in substitute command: '}'
Hi
Not sure if this is the correct place for this issue.
Just started using this npm package and it's great, it makes reading diffs in my terminal great.
However when I use git add --patch
it uses the old style diff to display each chunk that's about to be staged.
Is git add --patch
not supposed to use diff
under the hood, which is now diff-so-fancy
?
Is there anything we can do to use diff-so-fancy
with git add --patch
?
Thanks
e.g:
$> git dsf --cached test/
fatal: ambiguous argument '@$': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Instead we can use bash function to make the alias work with pipes and all.
Now that it's in a real readme, maybe you want to clean out the inline docs.
you can definitely remove the TODO about npm, since you did that. :)
I'm not an expert on git config manual editing, but adding
git config --global core.pager "diff-highlight | diff-so-fancy | less --tabs=1,5 -R"
to my git config on mac was invalid.
Running git config --global core.pager "diff-highlight | diff-so-fancy | less --tabs=1,5 -R"
, however, added this line under core
[core]
pager = diff-highlight | diff-so-fancy | less --tabs=1,5 -R
Sometimes, i do want to get a patch from git diff
. Is there an easy way to do that once i have turned on diff-so-fancy
git config?
Some people like myself might actually prefer to have the +
and -
on the left but still benefit from the other improvements. Feasible?
Please see the image. I'm using the Solarized Dark xterm-256color theme from https://github.com/mathiasbynens/dotfiles
Prior to using diff-so-fancy, I would often use /^diff or /^commit in less to jump between files/commits.
With diff-so-fancy, I've found I can pre-seed less with the search pattern (-p) which is nice because then I can immediately start hitting "n/p" to jump between matches, but I'm still trying to figure out the most useful regex to use..
Currently I'm using:
diff-so-fancy | less --tabs=4 -RFX -p'^ -- |^commit'
which is ok, but it would be a little nicer if I could match the line above, which is the ────
line (unfortunately, I don't think there's an easy way to distinguish it from the second ────
line which appears below the filename).
If this is the sort of thing lots of people do (and not just my own personal weirdness), then maybe diff-so-fancy should help out with making the blocks more matchable.
The top commit line in my git log was swallowed by it, for example. I had to revert to the previous version.
We've done an amazing job so far! Thank you everyone 😄
dsf
alias in docs (bb427e8)Is there anything we missing before a new release?
We're lacking tests for a few areas. Let's use this ticket to track them.
Please add any others you think we'll need! Edit or leave a comment.
After updating to today's master I have some artifacts with the character n
in my diff header.
@pauley-unsaturated do you think it may be your fixes?
I get this result after brew rm gnu-sed
. If it's installed, things are looking fine.
For the following diff:
diff --git a/src/components/navigation/Navigation.jsx b/src/components/navigation/Navigation.jsx
index b8babac..a68d90f 100644
--- a/src/components/navigation/Navigation.jsx
+++ b/src/components/navigation/Navigation.jsx
@@ -47,7 +47,7 @@ export default class Navigation extends React.Component {
if (this.state.navigations !== null) {
// 3 left, 5 right
leftNavigation = <NavigationList navigations={ _.take(this.state.navigations, 3) }/>;
- myAccountNavigation = <NavigationList navigations={ _.takeRight(this.state.navigations, 5) }/>;
+ myAccountNavigation = <NavigationList navigations={ _.takeRight(this.state.navigations, 4) }/>;
}
const _className = `component-navigation${ this.state.open ? ' open' : ''}`;
Running git-diff | diff-so-fancy
yields this error:
sed: 1: "/^((\x1B\[([0-9]{1,3}(; ...": bad flag in substitute command: '}'
npm is fine for us who do a lot of JS, but it's not convenient for people who don't. This project uses no JavaScript, so it really has no hard dependency on npm.
It'd be great if you could install this in a different, more common way.
Thanks so much for this awesome tool! Is there a way to make it show added or removed empty lines? I see the added space from the new lines in my diff, but they aren't highlighted at all. (I installed it on OS X, following your instructions to a tee, including all of your suggested changes to my Git config.)
$ brew install diff-so-fancy
Error: No available formula for diff-so-fancy
Searching formulae...
Searching taps...
$ brew search diff-so-fancy
No formula found for "diff-so-fancy".
Searching pull requests...
Closed pull requests:
diff-so-fancy 0.4.0 (https://github.com/Homebrew/homebrew/pull/49222)
diff-so-fancy 0.3.0 (new formula) (https://github.com/Homebrew/homebrew/pull/49040)
Install on mac results in;
$ brew install diff-so-fancy Error: No available formula with the name "diff-so-fancy" ==> Searching for similarly named formulae... Error: No similarly named formulae found. ==> Searching taps... Error: No formulae found in taps.
Totally loving the new diffs, making my working life much more fun 🙂️
Thing is, you've spoiled me, and I kinda want them everywhere now. I had a quick grep about but couldn't find anything. Does anyone out there know a way to modify the command that generates the patch diffs? I would be happy to implement if someone can point me in the right direction.
In case someone is reading this and thinking "What's a patch diff?" do git commit -p
from somewhere dirty.
I'm using the suggested defaults (see below) and I wanted to change the meta
color to just yellow (not bold). Setting it to yellow
gives me a brownish color, so I used 11
instead. This gives me the color I want, but reverts the style of the header to the old raw diff style.
[color "diff"]
meta = yellow bold
commit = green bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
Not sure if this is to be included into the repo, but I found that using the pipe combo is bit much of typing, so I rolled this:
Removal of the initial +/- interacts poorly with merge diffs, which have two initial columns of indicators.
I also suspect octopus merges can have even more.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.