Live data from Hacker News

Delta: A syntax-highlighting pager for Git, diff, grep, and blame output

github.com

91–98 of 98 posts

Re: Delta: A syntax-highlighting pager for Git, diff, grep, and blame output

#91

Earlier quoted context omitted.

You say that like it’s a bad thing? Default git diff output is soooooooooo bad. This tool makes it closer to a good GUI tool. At which point why not just use one of the tools that is excellent and existed for decades?

Because some people, prefer to use their terminal as their universal IDE. Most of the time, diffs are small, and the overhead/break in workflow, of starting a separate GUI program just for them, can be big.

I probably do git status; git diff; git commit; 20+ times a day sometimes. Leaving the terminal in the middle for the diff is unfathomable to me.

Re: Delta: A syntax-highlighting pager for Git, diff, grep, and blame output

#92
post #91

Earlier quoted context omitted.

Because some people, prefer to use their terminal as their universal IDE. Most of the time, diffs are small, and the overhead/break in workflow, of starting a separate GUI program just for them, can be big.

I probably do git status; git diff; git commit; 20+ times a day sometimes. Leaving the terminal in the middle for the diff is unfathomable to me.

It's so fun how different people work.

I can't fathom git diff in the terminal providing me value... ever? It's such a crappy and limited tool. My brain never learned to parse the +/- lines. I want a side-by-side view.

Which the linked tool does side-by-side. But I don't really run a diff unless it's for something non-trivial. In which case terminal still kinda sucks.

I don't see popping into a GUI as a loss. It's fast and snappy. No loss.

There's a class of programmers that seemingly live almost their entire life in the terminal. I've never been part of that class. My career has always been spent in a an IDE like Visual Studio, VSCode, or these days 10x. And that's assuming I'm not in something like Unity or Unreal. The terminal is something I regularly alt-tab to. It's never somewhere I stay.

Re: Delta: A syntax-highlighting pager for Git, diff, grep, and blame output

#93
post #68

Why? How does syntax coloring help in this context? I don't use syntax coloring at all in my editor, I don't think it adds any information or clues that help me understand the code. I think colored diff output (beyond red for deleted and green for added) just adds distractions.

Delta can show in the terminal a diff that looks like the GitHub one. You can compare side by side what was changed. It also highlight with more strength what changed inside the line. I installed it once, and never came back to the standard diff output. If Delta doesn't work like you expected and you want a standard diff output temporarily, no problem, you can run Git with git -c core.pager=less Note also that if you…

That tells me what Delta does, but not why I might want syntax highlighting in the diff context. I want to quickly see the differences, not a kaleidoscope of colors.

I normally use vimdiff and lazygit to see diffs. No syntax coloring.

Re: Delta: A syntax-highlighting pager for Git, diff, grep, and blame output

#94
post #78

There was a good point made, that has stuck with me over the years. that our syntax highlighters are highlighting the wrong thing. They should not be coloring the grammar, we are good at picking out grammar, they should be highlighting the symbols. each different variable and function name should be getting it's own color. that is, the goal is to make it quicker to distinguish different symbols, not that they are a s…

We are pretty good at picking out variable names too... Especially if the grammar itself is highlighted since we then know exactly where to look / where not to look.

I'm not convinced of the argument, but still a bit curious.

I sometimes highlight a variable to follow it and make sure I don't miss an instance of it, so that I totally get. But not sure we have enough colors and contrast to make sense to follow many variables without cluttering everything up. A compromise might be to manually color up to 3 or something variables.

... but the cases where that helps may be a sign that the code isn't very readable to begin with (helping with messy codebases is a proper usecase though!).

Re: Delta: A syntax-highlighting pager for Git, diff, grep, and blame output

#95

Delta has been one of those set and forget things, it's been a while since I've seen 'bare' git grep/diff/blame output, I also use it all the time for normal diffs (outside of git repos), but TIL that it also works with ripgrep [0] As someone else already mentioned there is also bat[1], which was also set and forget, I aliased cat to bat and have a seperate alias vcat for 'vanilla cat' /usr/bin/cat [0] https://dandav…

You can use \cat to prevent alias expansion.

I have ‘ccat’ aliases to the original cat binary

Re: Delta: A syntax-highlighting pager for Git, diff, grep, and blame output

#97
post #89

Here's a handy delta trick for you, to turn the side-by-side feature on and off based on window size. bash here, other shells left as an exercise: function delta_sidebyside { if [[ COLUMNS -ge 120 ]]; then DELTA_FEATURES='side-by-side' else DELTA_FEATURES='' fi } trap delta_sidebyside WINCH

You are probably missing a $ before COLUMNS and export before setting DELTA_FEATURES

Re: Delta: A syntax-highlighting pager for Git, diff, grep, and blame output

#98
post #89

Here's a handy delta trick for you, to turn the side-by-side feature on and off based on window size. bash here, other shells left as an exercise: function delta_sidebyside { if [[ COLUMNS -ge 120 ]]; then DELTA_FEATURES='side-by-side' else DELTA_FEATURES='' fi } trap delta_sidebyside WINCH

You are probably missing a $ before COLUMNS and export before setting DELTA_FEATURES

Bash is funny with the -gt, -lt etc. operators and the [[ ]] builtin -- bash treats them as arithmetic operators like it does with math in $(( )), and so you provide them the variable name, not the value.

    $ TEST=3
    $ if [[ TEST -gt 2 ]]; then echo "honk"; fi
    honk
    $ TEST=1
    $ if [[ TEST -gt 2 ]]; then echo "honk"; fi
    $
That lets you do things like

    $ if [[ TEST*3 -gt 6 ]]; ...
without having to nest even more double parentheses.

You're correct about having to export DELTA_FEATURES at least once. (I export it outside of the function, but no harm in doing so whenever it's set -- but it's not required to re-export it when you change the value.) Thanks for catching that!

Post reply on HN