banga / git-split-diffs

Syntax highlighted side-by-side diffs in your terminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`--color` option breaks the output in Git Bash on Windows

mtsknn opened this issue · comments

$ git diff data/slugify.js | git-split-diffs | less

Correct output without colors


$ git diff data/slugify.js | git-split-diffs --color | less

Garbled output when using --color

(Truncated output; there are a few more lines.)


$ git --version
git version 2.31.1.windows.1

$ node -v
v14.13.0

$ npm ls -g --depth=0
C:\Users\mts\AppData\Roaming\npm
├── git-split-diffs@0.10.0
...

Any idea what might be wrong? I'm using Windows Terminal in the screenshots, but the --color option doesn't work either when used directly in Git Bash.

The output seems to be colorized when using CMD, even without the --color option, but I don't want to use CMD. (Btw the output looks gorgeous! 🤩)

From todo.md I can see that there's a completed item called "Test on windows." I wonder what kind of setup was used for the testing? Was CMD or Git Bash used?

From todo.md I can see that there's a completed item called "Test on windows." I wonder what kind of setup was used for the testing? Was CMD or Git Bash used?

I tested on a fresh Windows 10 VM in VirtualBox, both with CMD and Git Bash:

$ git --version
git version 2.31.1.windows.1

$ node -v
v14.16.1

From the screenshot, it seems that the ANSI color codes are not being interpreted. I'd guess that this has to do with the TERM environment variable. For me it is set to xterm in git bash and unset in CMD and colors work in both. Can you check that?

Thank you!

$ echo $TERM
xterm-256color

I just noticed that if I don't pipe the output to less, everything works perfectly. So the problem is actually in the less command.

From superuser.com/q/117841/111704 I learned that I need to use the -R flag with less. -r seems to work as well.

So now it's working, and it's beautiful!

Hmm, now I noticed that the less commands in the "Install globally" and "Install locally" sections in the readme use the flags -RFX. Maybe the command in the "Use manually" section should also use at least the -R flag?

Oh yes, thanks. I'll update it