Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

While everyone is here considering their life choices (at least as far as they relate to ~/.gitconfig), highly recommend delta [1] as a companion to the git cli.

[1]: https://dandavison.github.io/delta/



After using delta for a while, I'm going back to the regular diff view... it's not that it isn't good, but I'm constantly copying diffs (yes, I know I can generate patches) and the pretty output breaks that workflow.

Also, when your terminal is a bit small it's a bit hard to see things. But it's really good software, I recommend anyone who's reading to give it a try.


IIRC if you pipe the output to, e.g, xclip, or redirect to a file it will give the original diff format. Not as convenient, but still workable.


I... did not know that! Yep yep that should do the trick for me. Thanks a lot, actually!


Most tools that do formatted output, if they’re well-behaved, should try to detect if their output is a pipe and if so, disable formatting.

Some examples that I can think of off the top of my head (in addition to git) are ripgrep and jq, both of which do the right thing and strip formatting.


rather they should detect that output is a terminal and enable the coloring


Wow I never knew this, I always just type `--no-ext-diff` when piping the output. Thanks!


`... | cat` is sometimes really handy (and universal)


I use git -c core.pager = less, but piping seems to be a less verbose option... hmmm I'll try it


Pipe through cat should work


Isn't copying without the formatting just a `<your diff command> | pbcopy` away?


I have Gemini set to decipher HN comments that I don't immediately understand. This is a macos only command `pbcopy`?

Aside: Gemini mentioned it didn't want me to ask it questions about bikeshedding what shade of blue on a website header so I think it's got our number.


Though, if you have a preferred shade of blue, you can actually use it for the HN header in your user settings.


Yes pbcopy is a mac thing. On Linux, there are of course many different commands in different environments/distros. xsel, xclip, wl-clipboard, wlclip to name a few.

On windows, powershell has Get-Clipboard and Set-Clipboard, and cmd.exe has `wsl` to fix the issue of having used cmd.exe to begin with.


There's also clip(.exe) on every version of Windows I've bumped into recently.


On Linux I made a ~/bin/pbcopy that does the right thing because all the Linux commands are stupidly difficult to remember compared to "pbcopy".


If you’re an emacser, you can even use delta with magit via the same author’s magit-delta package: https://github.com/dandavison/magit-delta

Looks like there are also instructions in the docs for using it with vscode


I really wanted to add this (I linked it in the last paragraph) but I really wanted to keep the recommendations globally applicable in vanilla git. Delta is awesome though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: