How do I determine if a terminal is color-capable?

后端 未结 3 861
说谎
说谎 2020-12-08 10:02

I would like to change a program to automatically detect whether a terminal is color-capable or not, so when I run said program from within a non-color capable terminal (say

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 10:23

    Look up the terminfo(5) entry for the terminal type and check the Co (max_colors) entry. That's how many colors the terminal supports.

提交回复
热议问题