我最近在 ssh 进入的机器上安装了 GNU screen。如何让 GNU 屏幕使用 256 色?
到目前为止,我已经尝试将以下内容添加到我的.screenrc:
term screen-256color
Run Code Online (Sandbox Code Playgroud)
和
attrcolor b ".I" # allow bold colors - necessary for some reason
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' # tell screen how to set colors. AB = background, AF=foreground
defbce on # use current bg color for erased chars
Run Code Online (Sandbox Code Playgroud)
但都没有奏效。
在登录 shell 中,在启动 screen 之前,当我运行这个打印 256 色的脚本时,我得到了正常的输出。当我使用命令时,tput colors我得到了输出8。
当我启动 screen 并运行脚本时,我得到 16 种颜色映射到 256 种颜色 - 有大块纯色。当我运行时,tput colors我得到256(何时term screen-256color在我的 .screenrc 中)。
编辑:我让它工作了 - 我没有使用该--enable-colors256选项配置屏幕。
Pan*_*her 15
我个人把它放在 ~/.bashrc
export TERM=xterm-256color
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,您使用的是什么终端?
小智 9
如果您从源代码构建屏幕,则需要在启用 256 色标志的情况下重新编译它。跑./configure --enable-colors256 && make && sudo make install