TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

642 pointsby nateb20226 months ago

25 comments

SushiHippie6 months ago
Delta has been one of those set and forget things, it&#x27;s been a while since I&#x27;ve seen &#x27;bare&#x27; git grep&#x2F;diff&#x2F;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]<p>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 &#x27;vanilla cat&#x27; &#x2F;usr&#x2F;bin&#x2F;cat<p>[0] <a href="https:&#x2F;&#x2F;dandavison.github.io&#x2F;delta&#x2F;grep.html" rel="nofollow">https:&#x2F;&#x2F;dandavison.github.io&#x2F;delta&#x2F;grep.html</a><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;sharkdp&#x2F;bat">https:&#x2F;&#x2F;github.com&#x2F;sharkdp&#x2F;bat</a>
评论 #42092629 未加载
somat6 months ago
There was a good point made, that has stuck with me over the years. that our syntax highlighters are highlighting the wrong thing.<p>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&#x27;s own color. that is, the goal is to make it quicker to distinguish different symbols, not that they are a symbol.<p>But this is much harder than stylizing the grammar so all our tooling sticks with the easy thing rather that the useful thing. Now, I am being a bit mean on grammar styling. It does help quite a bit but I would like to see a symbol matching engine in action to see if that really works.<p>Unfortunately I don&#x27;t remember where I read the original post and am unable to attribute it correctly.<p>update: while trying to look it up I found this <a href="https:&#x2F;&#x2F;www.wilfred.me.uk&#x2F;blog&#x2F;2014&#x2F;09&#x2F;27&#x2F;the-definitive-guide-to-syntax-highlighting&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.wilfred.me.uk&#x2F;blog&#x2F;2014&#x2F;09&#x2F;27&#x2F;the-definitive-gui...</a>
评论 #42098037 未加载
评论 #42097415 未加载
评论 #42097855 未加载
评论 #42109912 未加载
montroser6 months ago
Not as fancy, but if you want halfway reasonable word-level diffs with just standard issue git, this is often good enough:<p><pre><code> git diff --color-words --word-diff-regex=&#x27;\w+|.&#x27;</code></pre>
评论 #42093632 未加载
CGamesPlay6 months ago
Delta is great for what it does, but I consistently hit an issue where it truncates long lines. This post inspired me to check if the situation had changed... and it has! Now if you set `git config --global --replace-all delta.max-line-length 0`, it will no longer truncate lines. It&#x27;s unclear to me why this is not the default. Discussion about the change is in <a href="https:&#x2F;&#x2F;github.com&#x2F;dandavison&#x2F;delta&#x2F;pull&#x2F;290">https:&#x2F;&#x2F;github.com&#x2F;dandavison&#x2F;delta&#x2F;pull&#x2F;290</a>.
评论 #42093036 未加载
atombender6 months ago
Speaking of diffs, one thing that annoys me about Git&#x27;s diff output is that is prints file paths like Unix diff traditionally does, starting with the two file names:<p><pre><code> --- a&#x2F;some&#x2F;path&#x2F;to&#x2F;file.c +++ b&#x2F;some&#x2F;path&#x2F;to&#x2F;file.c </code></pre> I often cmd-click in iTerm to open a file in an editor, but this doesn&#x27;t work here because of the a&#x2F; and b&#x2F; prefixes. Any way to make Git format the file name better? I don&#x27;t even need two lines here.
评论 #42093609 未加载
评论 #42093606 未加载
评论 #42093681 未加载
kjuulh6 months ago
I&#x27;ve been using a mix of delta and difftastic both are amazing. Difftastic especially for tree-sitter AST syntaxes, it is a bit slower, but AST aware diff is so nice.<p>Delta looks clean, and is super fast
wlonkly6 months ago
Here&#x27;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:<p><pre><code> function delta_sidebyside { if [[ COLUMNS -ge 120 ]]; then DELTA_FEATURES=&#x27;side-by-side&#x27; else DELTA_FEATURES=&#x27;&#x27; fi } trap delta_sidebyside WINCH</code></pre>
评论 #42113233 未加载
signal116 months ago
I use both delta and difftastic (difft), and cannot recommend them enough.<p>If you use the terminal at all, get them!
评论 #42091862 未加载
评论 #42092472 未加载
nikolahorvat6 months ago
Also, checkout tig: <a href="https:&#x2F;&#x2F;jonas.github.io&#x2F;tig&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jonas.github.io&#x2F;tig&#x2F;</a>
commandersaki6 months ago
I want to like this having used regular `git diff` tool with colours, but this is just too busy.
评论 #42092477 未加载
评论 #42092887 未加载
dr_kretyn6 months ago
The thing that prevents me from using delta is lack of &quot;system&quot; theme detection. Can&#x27;t set it up and forget and mismatching theme with shell makes it really difficult to read.
评论 #42092388 未加载
评论 #42092297 未加载
_def6 months ago
I saw this recently and thought &quot;great!&quot; and tried it out, thinking I would love it. But somehow I actually prefer the way git already does it, even if it seems inferior to me. Maybe I&#x27;d just have to get used to it?
评论 #42095029 未加载
PhilipRoman6 months ago
I use a modified version of vimdiff as my daily diff tool: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;PhilipRoman&#x2F;60066716b5fa09fcabfa6c95eaf7d170" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;PhilipRoman&#x2F;60066716b5fa09fcabfa6c95...</a><p>I find it easier to navigate that way since the diff of each file is in its own tab (yes I know... not how tabs are meant to be used)<p>For grep, vim&#x27;s built in location list seems good enough. As for blame, I haven&#x27;t used it since learning about git log -L. Vastly superior in my opinion.
sixhobbits6 months ago
What&#x27;s a good way to convert the output of something like this into an html page?<p>We have non technical people looking at markdown PRs and commits in github and the diff viewer is terrible. It will highlight and entire paragraph because someone removed a trailing space. I use git-so-fancy locally which makes it much easier to see changes but I can&#x27;t expect non-technical editors to move from their GitHub based workflow to a terminal based one
评论 #42094033 未加载
评论 #42093998 未加载
评论 #42093745 未加载
djbusby6 months ago
I&#x27;m still on diff-so-fancy; Worth investigating this one?
评论 #42093717 未加载
评论 #42092302 未加载
评论 #42092426 未加载
评论 #42092132 未加载
psibi6 months ago
Looks like the author has also written magit integration for it: <a href="https:&#x2F;&#x2F;github.com&#x2F;dandavison&#x2F;magit-delta">https:&#x2F;&#x2F;github.com&#x2F;dandavison&#x2F;magit-delta</a><p>Any user feedback on how it is (perf etc) ?
评论 #42092183 未加载
pgray6 months ago
i like bat, but they also link over to delta :D<p><a href="https:&#x2F;&#x2F;github.com&#x2F;sharkdp&#x2F;bat?tab=readme-ov-file#git-diff">https:&#x2F;&#x2F;github.com&#x2F;sharkdp&#x2F;bat?tab=readme-ov-file#git-diff</a>
gigatexal6 months ago
I really like delta. I use it every day.
jgalt2126 months ago
This is pretty sweet. What&#x27;s the recommended color scheme for default Ubuntu purple background terminals?<p><a href="https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;dandavison&#x2F;delta&#x2F;main&#x2F;themes.gitconfig" rel="nofollow">https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;dandavison&#x2F;delta&#x2F;main&#x2F;them...</a>
tomxor6 months ago
i knew git could use arbitrary diff filter but never realised it was this simple to use. This looks very nice.<p>The related? project &quot;bat&quot; also looks interesting.
评论 #42091866 未加载
评论 #42092144 未加载
nfrmatk6 months ago
I&#x27;ve been using Delta for a few years now and absolutely love it. Huge improvement to my command line diff viewing!
benreesman6 months ago
I love delta, I don’t always run it but I usually do. I recommend anyone give it a try.
gregjor6 months ago
Why? How does syntax coloring help in this context? I don&#x27;t use syntax coloring at all in my editor, I don&#x27;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.
评论 #42094186 未加载
edwinksl6 months ago
Been using delta for diffs for a while, highly recommend it!
forrestthewoods6 months ago
I’ve been using Araxis Merge for almost 20 years. This seems… not as good?
评论 #42092307 未加载
评论 #42092106 未加载
评论 #42093000 未加载