bat: Incorrect colours on Windows

(copied from my comment in #107)

I installed bat on a recent Windows 10 Pro x64 build today and tried it in Cmder, the Cmder installation of ConEmu, PowerShell, and the regular Command Prompt. The first two gave me this:

White-on-grey text everywhere except the filename

PowerShell gave me this (presumably just different default terminal colours; please excuse the crude black censor bar):

White-on-pink text everywhere except the filename

Command Prompt gave me this, like the first two:

White-on-grey text everywhere except the filename

bat looks really exciting and I’m eager to use it, so I hope this is just a misconfiguration on my end! FWIW, I get the same results without a BAT_THEME and with a BAT_THEME of Monokai Extended Bright.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 18 (15 by maintainers)

Most upvoted comments

Colours work for me after installing the version found on Chocolatey.

PS> Get-Command less

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     less.exe                                           0.0.0.0    C:\Program Files\Git\usr\bin\less.exe

PS> less --version
less 529 (PCRE regular expressions)
Copyright (C) 1984-2017  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less

PS> bat .\readme.md
# no colours...
PS> choco install less
PS> Get-Command less

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     less.exe                                           0.8.1.0    C:\ProgramData\chocolatey\bin\less.exe

PS> less --version
less 529 (Spencer V8 regular expressions)
Copyright (C) 1984-2017  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less

PS> bat .\readme.md
# all the colours

Done, #295.

Ah, I see. I have to specify the full path to less since it’s not the default one, so in my case, BAT_PAGER != "less". I just tried swapping the order so that the default one is correct, and it solved everything—no environment variables required! I do still see the issue with encoding if I set BAT_PAGER to the full path and set LESS to include either -r or -R, if that’s something you want to look into, but it seems like my issue is solved. Thank you very much for following up on this.

EDIT: It just needed LESSCHARSET to be set to utf-8, which bat does if the executable is less or ends with /less, which is not the case with an absolute path or a filename with extension on Windows.

Maybe, although I really wish I could figure out a way to have my paging ~and eat it too~. Alternatively, paging could be opt-in only on Windows.