在Linux控制台中使用256色
Linux控制台和xterm可以支持256种颜色定义,在转义序列中使用256色的语法:
Set the foreground color to index N: | \033[38;5;${N}m
|
Set the background color to index M: |
|
${N}代表颜色代码的变量,当然也可以写常量值,例 如:\033[00;38;5;51m
我的PS1是这样写的
PS1='\[\033[01;33m\][\u:\[\033[00;38;5;51m\]\W\[\033[01;33m\]\$]\033[00m'
PROMPT_COMMAND='echo -ne "\033]2;${PWD}\007"'
具体的颜色定义可以到这个页上下载脚本程序来查看:http://www.frexx.de/xterm-256-notes/