Pau*_*ce. 16
你可以用tput colors.
对于我的终端TERM=xterm-256colors输出是[drumroll] 256!以下是其他一些例子:
$ TERM=vt100 tput colors
-1
$ TERM=vt220 tput colors
-1
$ TERM=linux tput colors
8
$ TERM=cons25 tput colors
8
$ TERM=linux tput colors
8
$ TERM=rxvt-unicode tput colors
88
Run Code Online (Sandbox Code Playgroud)
或者,tput -Tvt100 colors您也可以指定您感兴趣的终端类型.