dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.32k stars 358 forks source link

🚀 Enable delta when producing a git log or diff in a shell pipeline #1731

Closed unphased closed 5 days ago

unphased commented 5 days ago

I have a huge and simple feature I want to add to delta git log browsing which is to enable OSC8 Hyperlink support in the files listed in delta's diffs.

Delta is my go-to git diff browser. Now that I use AI to write code more than I manually edit code, I spend a lot less time viewing git diffs via git diff and more time viewing diffs in git log -p. But that doesn't matter. For both git diff and git log -p the most practical way to add hyperlink support (which needs some custom reconciliation with code I've hooked into alacritty which does some slick logic for choosing the correct nvim instance to puppeteer) I need to just send the output of git diff and git log -p (in particular rendered via delta) into a shell script so I can do some simple work with sed to have all file paths become properly hyperlinked.

This is proving difficult as once you run either of these from a shell script they will not get delta pager goodies. I can't get it by specifying GIT_PAGER as delta either though that was a long shot anyway. I'd like for there to exist a way to force git to produce a diff or log with the usual features (ability to specify more flags if necessary) but while forcing delta on always.

It may be possible to use some PTY wrapper tool but this is not the answer, because it would be only be receiving just the first page of the paged output.

unphased commented 5 days ago

I believe a standard pattern is intended to fulfill my need, so I will close this but please do feel free to add any suggestions.

git log -p | delta does the trick for me and i can keep piping that on to do whatever I need. E.g.: git log -p | delta | sed s/a/z/g

unphased commented 5 days ago

note to onlookers, yeah i went down this path without reviewing documentation, hyperlinks had been added to delta like a year ago, and it is quite nearly enough for what i need. So don't be like me...