【发布时间】:2017-02-05 03:38:42
【问题描述】:
我想根据我当前所在的分支更改 Xterm 背景颜色。有什么好方法可以自动执行此操作吗?
目前我正在手动更改配置文件。我发现谷歌无法为我提供答案有点烦人。每个人似乎都只是通过更改提示来解决问题。
【问题讨论】:
标签: version-control xterm
我想根据我当前所在的分支更改 Xterm 背景颜色。有什么好方法可以自动执行此操作吗?
目前我正在手动更改配置文件。我发现谷歌无法为我提供答案有点烦人。每个人似乎都只是通过更改提示来解决问题。
【问题讨论】:
标签: version-control xterm
您可以从“修复提示”开始:其中一些答案涉及修改(bash 或 zsh)提示以发送更改窗口标题的转义序列。 xterm 的 背景颜色 只是另一个转义序列,属于同一组 Operating System Commands:
OSC Ps ; Pt BEL
OSC Ps ; Pt ST
Set Text Parameters. For colors and font, if Pt is a "?", the
control sequence elicits a response which consists of the con-
trol sequence which would set the corresponding value. The
dtterm control sequences allow you to determine the icon name
and window title.
...
The 10 colors (below) which may be set or queried using 1 0
through 1 9 are denoted dynamic colors, since the correspond-
ing control sequences were the first means for setting xterm's
colors dynamically, i.e., after it was started. They are not
the same as the ANSI colors. These controls may be disabled
using the allowColorOps resource. At least one parameter is
expected for Pt. Each successive parameter changes the next
color in the list. The value of Ps tells the starting point
in the list. The colors are specified by name or RGB specifi-
cation as per XParseColor.
...
Ps = 1 0 -> Change VT100 text foreground color to Pt.
Ps = 1 1 -> Change VT100 text background color to Pt.
使用 xterm(不一定适用于“xterm”模仿者...),
printf '\033]11;blue\007'
printf '\033]11;white\007'
将窗口背景更改为蓝色,然后更改为白色。
与“ANSI 颜色”的设置不同,动态颜色保持不变,不会被其他转义序列重置。
奇怪的是,xterm: how to change the background color? 建议使用“两种”(实际上是一种)不同的方式来设置背景颜色,但这对你的目的。
【讨论】: