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

Feature request: support input from git diff #274

Closed
morsdyce opened this issue Sep 4, 2018 · 2 comments
Closed

Feature request: support input from git diff #274

morsdyce opened this issue Sep 4, 2018 · 2 comments
Labels
duplicate This issue or pull request already exists question Further information is requested

Comments

@morsdyce
Copy link

morsdyce commented Sep 4, 2018

When viewing a file via bat filename we can see the file with the git diff perfectly as it shows in the readme example.

however if we try to use bat as our git diff tool (via setting pager property to bat in .gitconfig)
it doesn't understand how to separate the files and show the correct diff with the correct syntax highlight.

image

It would be awesome if we could support git syntax so we can highlight these correctly.

similar to how https://github.com/so-fancy/diff-so-fancy works

@sharkdp
Copy link
Owner

sharkdp commented Sep 4, 2018

Thank you for the feedback.

git diff will add colors on its own. This is why you see some colors in the screenshot above. You can also use

git diff | bat -ldiff

which will show you the diff, highlighted by bat.

However, I think what you really want is something like #23 (see my proposal in this comment). This would allow us to show every modified hunk in a Git repository with syntax-highlighted code.

@sharkdp sharkdp added duplicate This issue or pull request already exists question Further information is requested labels Sep 5, 2018
@sharkdp sharkdp closed this as completed Sep 7, 2018
@coolaj86
Copy link
Contributor

coolaj86 commented Sep 26, 2024

For posterity:

Here's how you set it to work with git diff and replace the general pager.

git config --global core.pager "bat --theme Dracula --style=plain"
git config --global pager.diff "bat --paging never --pager none --theme Dracula --style=plain --language diff"

Season to taste, of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants