如何打印 xterm 标题?

How can I print the xterm title?

我有一个网络模拟器 (mininet),可以为我模拟交换机和主机。我可以通过 xterm 开关来发送数据包。 我想在终端中打印 "xterm title"。例如 xterm 标题是 "Node:s1"(root),我在名为 "Node:s1"(root) 的 xterm 中搜索打印 "Node:s1(root)" 的命令。您知道可以打印 xterm 标题的命令吗?

如果那是 xterm, you can do this. Other terminals may have the relevant code disabled (permanently), but with xterm, you can configure it and get the title string. In the manual page,那就是 allowWindowOps 资源。

xterm(和类似程序)让应用程序通过向其发送转义序列来设置标题。还有另一个转义序列要求终端将标题字符串发送回主机。如果主持人不希望这样做,并且字符串包含命令,则您的 shell 将执行这些命令。

开始阅读的地方是xterm title HOWTO

较新版本的 xterm 对于只想设置和恢复标题的应用程序具有不同的功能。这说明了大多数设置标题的应用程序,例如 GNU 屏幕。正好GNU screen can use this newer xterm feature. It's only been around 6 years (November 2009),所以其他程序还没赶上

延伸阅读: