1

So, my goal is to figure out what amount of color support a system has. What I mean by this is create a function supportsColor() that checks how many colors can be displayed in sys.stdout, returning 0 for no color, 1 for 16 different colors support, 2 for 256 different colors support, and 3 for Truecolor (basically any colors).

An example (js package) of how it should work is this: https://github.com/chalk/supports-color

sawbez
  • 29
  • 3
  • 1
    Have you looked at how that JS works? It has lots of checks for different operating systems, terminal emulators, etc. There's no generic way to do this, it just knows what every terminal application supports. – Barmar Apr 29 '22 at 23:16
  • Related; [How to detect if the console does support ANSI escape codes in Python?](https://stackoverflow.com/q/7445658/11082165) – Brian61354270 Apr 29 '22 at 23:19
  • A very rough approximation can be gotten with the `TERM` environment variable. On my terminal right now, I see `xterm-256color`. – Silvio Mayolo Apr 29 '22 at 23:19

0 Answers0