幽谷奇峰 | 燕雀鸣幽谷,鸿鹄掠奇峰

如何查看Linux终端是否支持256色


运行以下命令, 若256种颜色全部输出,就表示支持256色。

1
$ (x=`tput op` y=`printf %76s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done)

下列命令会输出你所支持的所有终端模拟器,以及它们支持的颜色位数,可能的值有:8, 15, 16, 52, 64, 88 和 256.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ for T in `find /usr/share/terminfo -type f -printf '%f '`;do echo "$T `tput -T $T colors`";done|sort -nk2|tail -n20

wy370-wvb 64
Eterm-88color 88
rxvt-88color 88
xterm-88color 88
xterm+88color 88
Eterm-256color 256
fbterm 256
gnome-256color 256
iTerm.app 256
konsole-256color 256
mlterm-256color 256
mrxvt-256color 256
putty-256color 256
rxvt-256color 256
rxvt-unicode-256color 256
screen-256color-bce-s 256
screen-256color-s 256
terminator 256
vte-256color 256
xterm+256color 256

可以在终端的配置文件,例如.bashrc中加入以下内容,使其支持256色:

1
export TERM=vte-256color

参考资料:


本作品由 Yysfire 创作,采用知识共享许可协议进行许可。转载时请在显著位置标明本文永久链接:
http://yysfire.github.io/linux/how-to-check-linux-terminal-whether-support-256-colors.html


相关文章


最后修改
2012-12-07 23:01
发表时间
2012-12-03 11:20
本文标签
256 color 1 Color 3 Linux 18 TERM 1 Terminal 3
关注我