An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
TIL: diff-so-fancy; and some funky git config
I just discovered diff-so-fancy
, and very nice it is too. I immediately added it to my standard git config, which is semi-automatically installed on every machine I use. However, I've not (yet) installed diff-so-fancy
on all the machines I use, and for those platforms for which it's not packaged I probably won't bother installing it from source.
But if I just follow the author's instructions which amount to adding this to my ~/.gitconfig
:
[core] pager = "diff-so-fancy | less --tabs=4 -RFX"
then git diff
will break:
$ git diff HEAD^diff-so-fancy | less --tabs=4 -RFX: diff-so-fancy: command not found
but there's an easy fix! Whatever is in pager
is just shell code, so this works:
[core] pager = "if [ ! -z \"$(which diff-so-fancy)\" ]; then diff-so-fancy | less --tabs=4 -RFX; else less; fi"
The output from git diff
is piped into that little script. If diff-so-fancy
is installed (ie if "$(which diff-so-fancy)"
is not zero-length) then it does exactly what diff-so-fancy
's author suggests. Otherwise, if diff-so-fancy
isn't installed, just run less
.
Original Link: https://dev.to/drhyde/til-diff-so-fancy-and-some-funky-git-config-2a2o
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To