【发布时间】:2023-12-03 09:53:01
【问题描述】:
通过在终端中使用 ANSI 序列 Esc[39m,可以清除前景色而不改变其他属性,如粗体、下划线或背景色。例如:
echo -e "\e[31;1mRed and bold.\e[39m Bold only."
我想从 terminfo 功能中检索此序列,但我找不到它;尝试使用setaf 9 时,它会通过给出序列Esc[91m 切换到明亮的颜色:
$ tput setaf 1 | xxd
00000000: 1b5b 3331 6d .[31m
$ tput setaf 9 | xxd
00000000: 1b5b 3931 6d .[91m
我发现重置前景色的唯一功能是sgr0,但它也会重置所有其他属性。
是否可以从 terminfo 访问这些功能?
- 默认前台
Esc[39m; - 默认背景
Esc[49m;
【问题讨论】: