我正在寻找一个包含以下内容的文件
export fgBlack8="$(tput setf 0)";
export fgRed8="$(tput setf 1)";
export fgGreen8="$(tput setf 2)";
export fgYellow8="$(tput setf 3)";
export fgBlue8="$(tput setf 4)";
export fgMagenta8="$(tput setf 5)";
export fgCyan8="$(tput setf 6)";
export fgWhite8="$(tput setf 7)";
export bgBlack8="$(tput setb 0)";
export bgRed8="$(tput setb 1)";
export bgGreen8="$(tput setb 2)";
export bgYellow8="$(tput setb 3)";
export bgBlue8="$(tput setb 4)";
export bgMagenta8="$(tput setb 5)";
export bgCyan8="$(tput setb 6)";
export bgWhite8="$(tput setb 7)";根据这个链接:https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/
然后,当使用以下命令测试颜色时
echo -e "${fgBlack8}fgBlack8"
echo -e "${fgRed8}fgRed8"
echo -e "${fgGreen8}fgGreen8"
echo -e "${fgYellow8}fgYellow8"
echo -e "${fgBlue8}fgBlue8"
echo -e "${fgMagenta8}fgMagenta8"
echo -e "${fgCyan8}fgCyan8"
echo -e "${fgWhite8}fgWhite8"我收到以下输出:

红如蓝,黄如青,反之亦然。网站上的代码是错误的还是我用错了,并意外地产生了正确的颜色映射?
发布于 2019-02-23 06:45:58
如果您使用的是tput命令,那么从
$ man tput从看也会带你去
$ man terminfo你会发现
setaf/setab和setf/setb功能各采用一个数字论证。终端硬件可以随意映射它们,但RGB值表示颜色空间中的正常位置。 颜色#定义值RGB黑色COLOR_BLACK 0,0,0红色COLOR_RED 1 max, 0,0绿色COLOR_GREEN 2 0,max,0黄色COLOR_YELLOW 3 max,max,蓝色COLOR_BLUE 4 0,0,最大品红COLOR_MAGENTA 5 max,0,max cyan COLOR_CYAN 6 0,max,max白色COLOR_WHITE 7 max,max,max setf/setb的参数值历史上对应于一种不同的映射,即, 颜色#定义值RGB黑色COLOR_BLACK 0,0,0蓝色COLOR_BLUE 1 0,0,最大绿色COLOR_GREEN 2 0,max,0 cyan COLOR_CYAN 3 0,max,最大红色COLOR_RED 4 max,0,0洋红COLOR_MAGENTA 5 max,0,max黄色COLOR_YELLOW 6 max,max,0白色COLOR_WHITE 7 max,max,max
https://stackoverflow.com/questions/54838578
复制相似问题