我搜索了一种更改终端标题的方法,并找到了这个 bash 命令:
echo -ne "\033]0;NEW_TITLE\007"
Run Code Online (Sandbox Code Playgroud)
它可以正常工作,但我现在对这个“魔法符号”的含义及其工作方式感兴趣。
它使用XTerm 控制序列。echowith-e解释给定字符串中的某些序列,在本例中\033变为Esc,并且\007是 ASCII 钟形字符(请参阅man 7 ascii)。
一个Esc(表示为^])后跟]在 XTerm 术语中是一个操作系统控制代码。支持它的终端将其解释为上述链接中给出的:
OSC Ps ; Pt ST
OSC Ps ; Pt BEL
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.
Ps = 0 -> Change Icon Name and Window Title to Pt.
Ps = 1 -> Change Icon Name to Pt.
Ps = 2 -> Change Window Title to Pt.
Run Code Online (Sandbox Code Playgroud)
OSC是^]],则Ps在这种情况下是0,该套Pt,在此情况下NEW_TITLE,作为终端标题。
有关的:
| 归档时间: |
|
| 查看次数: |
1515 次 |
| 最近记录: |