我的提示字符串是使用以下语句打印的,
printf '\033]0;%s@%s:%s\007' user host /home/user为什么它需要转义字符(\033)和钟形字符(007)?当我手动运行相同的命令时,它什么也不打印。
当我移除转义字符并发出命令时,
printf '%s@%s:%s' user host /home/user印出来了,
user@home:/home/user更容易理解。
那么,转义字符、\033和007如何转换为shell提示符字符串呢?
发布于 2015-06-09 10:31:25
只有\033是转义,它启动转义序列直到并包含;。\033]0;。这将启动一个字符串,该字符串设置终端标题栏中的标题,该字符串由\007特殊字符终止。
请参见man console_codes:
It accepts ESC ] (OSC) for the setting of certain resources. In addi‐
tion to the ECMA-48 string terminator (ST), xterm(1) accepts a BEL to
terminate an OSC string. These are a few of the OSC control sequences
recognized by xterm(1):
ESC ] 0 ; txt ST Set icon name and window title to txt.您没有看到任何更改,可能是因为您的提示在返回提示时将标题设置为默认的标题字符串。尝试:
PROMPT_COMMAND= ; printf '\033]0;Hello World!\007'https://unix.stackexchange.com/questions/208436
复制相似问题