Python 更改redhat中的标题,bash

Python 更改redhat中的标题,bash,python,bash,putty,Python,Bash,Putty,如何在python中更改putty标题 当启用python时,它会工作: # python >>> import sys >>> sys.stdout.write("\x1b]2;Another Title\x07") 以下操作不起作用: 在py中: # ./myscript myscript: #!/usr/bin/python import sys sys.stdout.write("\x1b]2;Another Title\x07") 回音 回声e

如何在python中更改putty标题

当启用python时,它会工作:

# python
>>> import sys
>>> sys.stdout.write("\x1b]2;Another Title\x07")
以下操作不起作用:

在py中:

# ./myscript
myscript:

#!/usr/bin/python
import sys
sys.stdout.write("\x1b]2;Another Title\x07")
回音

回声e

# echo -e "\x1b]2;Another Title\x07"
印刷品

:

PuTTY允许服务器发送xterm控制序列,在会话中期修改窗口的标题

:

3.1。xterm逃逸序列

在运行的xterm中,可以使用更改窗口和图标标题 XTerm转义序列。以下顺序在这方面很有用 尊重:

ESC]0;stringBEL-将图标名称和窗口标题设置为字符串 ESC]1;stringBEL-将图标名称设置为字符串 ESC]2;stringBEL-将窗口标题设置为字符串

其中ESC是转义字符\033,BEL是bell 字符\007

这意味着你想要的是:

$ printf "\033]0;My shiny new title\007"
注:不要将echo与选项-n/-e一起使用,它不可携带。

吉德尔谢谢

解决方案:
echo-e\027另一个标题\007

如果您指的是未展开的十六进制代码,我认为这是因为bash默认展开oct代码,请尝试\007。你能解释一下它是怎么不起作用的吗?太好了;echo-e\027另一个标题\007@flig按照手册的要求,无论是直接在bash shell中,还是在python shell中使用sys.stdout.write,都可以很好地工作。
# print
-bash: print: command not found
$ printf "\033]0;My shiny new title\007"