您的终端是否支持 88 色或 256 色模式?如果是这样,您可能应该使用像 xterm-88color 或 xterm-256color 这样的 TERM 值,而不是普通的 xterm。
inkpot 特别声明不支持仅支持 8/16 色的终端。从上方inkpot source:
" This should work in the GUI, rxvt-unicode (88 colour mode) and xterm (256
" colour mode). It won't work in 8/16 colour terminals.
设置语法着色的代码假定如果终端不支持 88 色,那么它必须支持 256 色。它不会尝试为 8 种颜色的情况提供后备值(例如,当 TERM=xterm 时)。如果终端似乎没有适当的颜色支持,inkpot 发出错误消息(并且没有修改颜色设置)也许会很好。
您看到的控制序列是由于尝试为该类型终端可接受输入的 0-7 范围之外的颜色编号生成 8 色终端颜色控制序列。因此,这些序列可能无效,但它们也不是完全有意的(因为 inkpot 假设支持 256 色,但 xterm terminfo 条目只知道如何处理基本的 8 色支持)。
例如,inkpot 在 88 色终端上将 Normal 语法前景色设置为 79;对于非 88 色终端(即 256 色终端,但也适用于您的 8 色 xterm),这将转换为 231。
当您尝试使用TERM=xterm 格式化此超出范围的颜色编号时,您会得到您找到的结果^[[3231m:
% tput -T xterm setaf 231 | od -a
0000000 esc [ 3 2 3 1 m
0000007
(即在^[[3和m之间插入231)
如果你使用xterm-256color,你会得到一个更正常的结果:
% tput -T xterm-256color setaf 231 | od -a
0000000 esc [ 3 8 ; 5 ; 2 3 1 m
0000013
(即在^[[38;5;和m之间插入231)
同样,Normal 语法 88 色背景颜色 80 被转换为 256 色值 232 并为xterm 生成错误的^[[4232m 序列(但会在下面生成更合理的^[[48;5;232m xterm-256color)。