Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bat --diff #940

Merged
merged 2 commits into from
Apr 24, 2020
Merged

bat --diff #940

merged 2 commits into from
Apr 24, 2020

Conversation

sharkdp
Copy link
Owner

@sharkdp sharkdp commented Apr 23, 2020

This PR adds a new --diff option that can be used to only show lines close to Git changes, i.e. added, removed or modified lines.

The amount of additional context can be controlled with --diff-context=N.

Using this like

batdiff() {
    git diff --name-only --diff-filter=d | xargs bat --diff
}

essentially results in a version of git diff with syntax highlighting (but without being able to see the old version).

image

closes #23

@sharkdp sharkdp force-pushed the diff-context-feature branch 2 times, most recently from e0f930d to f1beb72 Compare April 23, 2020 22:17
This adds a new `--diff` option that can be used to only show lines
close to Git changes (added/removed/modified lines). The amount of
additional context can be controlled with `--diff-context=N`.

closes #23
@sharkdp sharkdp force-pushed the diff-context-feature branch from f1beb72 to b0be7f1 Compare April 23, 2020 22:22
@sharkdp sharkdp changed the title Implementation of 'bat --diff' bat --diff Apr 23, 2020
@ErichDonGubler
Copy link

YASSS

There is much win here. :)

@sharkdp sharkdp force-pushed the diff-context-feature branch from 1e74ec7 to ec6b4c9 Compare April 24, 2020 07:17
@sharkdp sharkdp merged commit abeac8b into master Apr 24, 2020
@sharkdp sharkdp deleted the diff-context-feature branch April 24, 2020 07:58
@Mouvedia
Copy link

Does it support strike for color.diff.old?

@sharkdp
Copy link
Owner Author

sharkdp commented Apr 25, 2020

but without being able to see the old version

no

@ErichDonGubler
Copy link

Does it support strike for color.diff.old?

No, technically because this doesn't use Git config, but conceptually because...this doesn't display the old part of the diff.

@eth-p
Copy link
Collaborator

eth-p commented Apr 27, 2020

This is great! Do you mind if I add a variant of your batdiff wrapper to bat-extras?

@sharkdp
Copy link
Owner Author

sharkdp commented Apr 27, 2020

if I add a variant of your batdiff wrapper to bat-extras?

of course! 👍

JesseVermeulen123 added a commit to JesseVermeulen123/bat that referenced this pull request Oct 27, 2020
sharkdp pushed a commit that referenced this pull request Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter to only include hunks?
4 participants