bat: Default pager breaks colours in Windows Terminal
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:

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
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 24 (9 by maintainers)
@ofek I made a PR for scoop
https://github.com/ScoopInstaller/Main/pull/1108
Chocolatey is now using my version of less:
https://chocolatey.org/packages/Less
I have built
less version 560binaries 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.exesuch as version 429 by setting the following environment variable:Please note that this workaround is unnecessary for binary I am distributing in my GitHub repo.
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=neverinbats config file (bat --config-file):I can confirm that this is fixed with
Chocolateyandbat 0.15.1along withless 561. This was tested by using a fresh install ofbatviaChocolatey.I updated my binary version of
lesstov560which fixes an issue where colors were not being properly displayed underv557.https://github.com/jftuga/less-Windows
@sharkdp
lessno longer provides binaries 🙁I have messaged the Chocolatey
lessmaintainer with the link to my repo.https://chocolatey.org/packages/Less#discussion
@jftuga I’m using your builds, thanks!
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: