Bat: Default pager breaks colours in Windows Terminal

Created on 10 Mar 2020  路  24Comments  路  Source: sharkdp/bat

Hi, I've run into a bug in less that effectively breaks bat in the new Windows Terminal. I appreciate that this is not bat's fault, but I'm reporting it here to save other people the investigation time.

Bug

When calling bat in PowerShell in Windows Terminal, it breaks subsequent colouring in the terminal and makes it unusable (at least with my colour scheme) until the terminal is relaunched:

image

Details

This occurs for me in PowerShell (7 and 5.1) in Windows Terminal, it does not occur in the old Windows PowerShell application.

I _believe_ this is due to a bug in version 551 of the less pager, which is installed by default with the bat Chocolatey package. The issue has been fixed in less source, but it's not available via Windows package managers yet.

Short-term workaround

I was able to fix the issue by compiling version 554 of less, using the MinGW compilation instructions here.

Long-term fix

Wait for a newer version of less to be released via Chocolatey and Scoop.

What version of bat are you using?
bat 0.12.1 and less 551

How did you install bat?
Chocolatey


Windows 10 1909

bug upstream-error windows

Most helpful comment

All 24 comments

Thank you for the detailed bug report!

We can keep this open until it has been fixed in the Chocolatey package. Apart from that, I don't think there is anything we can do here except to suggest an (obvious) workaround, which would be to put --paging=never in bats config file (bat --config-file):

# Disable paging
--paging=never

less 557 has been recently released as a beta: http://greenwoodsoftware.com/less/download.html
The release notes mention "Fix display bug in WIN32C version."

Chocolatey:

Scoop:

In the meantime, @gwsw released less v559. It would be great if someone could verify if it (still) solves this issue. It would be even better, if #887 could also be tested (see this comment and 864656bd11d4f96235408e026f7ac68d86995919).

I have built less version 560 binaries for Windows. I have also documented the complete build process here:

https://github.com/jftuga/less-Windows

As a workaround, I have had good luck with really old versions of less.exe such as version 429 by setting the following environment variable:

BAT_STYLE=numbers,plain

Please note that this workaround is unnecessary for binary I am distributing in my GitHub repo.

I updated my binary version of less tov560 which fixes an issue where colors were not being properly displayed under v557.

https://github.com/jftuga/less-Windows

@jftuga Thank you very much for verifying this!

In this case, we only need to wait for the new releases to make it into Chocolatey/Scoop.

@sharkdp unfortunately as @ofek noted less is no longer providing binaries and the maintainer of the Chocolatey package is also dropping it.

In addition to the Chocolatey information, under the Paging section, you could also link to my repo.

This could possibly be a resolution to this issue.

@jftuga I'm using your builds, thanks!

@sharkdp unfortunately as @ofek noted less is no longer providing binaries and the maintainer of the Chocolatey package is also dropping it.

Oh, I missed the reference to the comment section of the Chocolatey package. That is unfortunate (not the fact that less does not distribute binaries, but the fact that Chocolatey does not build executables from source).

In addition to the Chocolatey information, under the Paging section, you could also link to my repo.

I'd be okay with that, but I would much rather like this to be solved on the Chocolatey side. Maybe they could use the binary (binaries) from your repo?

I have messaged the Chocolatey less maintainer with the link to my repo.

https://chocolatey.org/packages/Less#discussion

@jftuga Instead of (or in addition to) Chocolatey, can you please update Scoop? https://github.com/ScoopInstaller/Main/blob/master/bucket/less.json

Chocolatey is now using my version of less:

https://chocolatey.org/packages/Less

@jftuga Yay! Would you mind doing Scoop too? I (& many I know) avoid Chocolatey.

@jftuga Awesome work, thank you very much!

Can someone please confirm that the original bug has been fixed when freshly installing bat via Chocolatey?

I can confirm that this is fixed with Chocolatey and bat 0.15.1 along with less 561. This was tested by using a fresh install of bat via Chocolatey.

@jftuga Thank you!!!

@ofek I made a PR for scoop

ScoopInstaller/Main#1108

This has been merged as well :tada:. If anyone can confirm that everything works as expected when installing via Scoop, we can finally close this ticket.

Anyone here using the Scoop-installed version of bat?

@sharkdp Yes I have bat installed using scoop.

Ok, I'm going to close this for now. Let me know if this should re-appear in some setting.

Thank you all for your help.

Was this page helpful?
0 / 5 - 0 ratings