我可以获得终端所有权吗? (或以其他方式恢复旧的)
使用echo -e "\e]0;some title\007"
可以轻松设置终端标题。几乎适用于所有终端程序。
我想要的是在某个程序启动时设置终端标题 - 并在程序完成时恢复旧的标题。这可能吗?
Setting terminal title is easy with echo -e "\e]0;some title\007"
. Works with pretty much every terminal program.
What I want is to set terminal title when some program starts - and restore old one when it finishes. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 xterm 上,终端控制序列 22 和 23 工作正常,如下
所示Mac OS X Terminal.App 不支持这样的操作。
On xterm, the terminal control sequences 22 and 23 work fine, as in
It looks like this isn't supported in the Mac OS X Terminal.App though.
我的解决方案是在脚本过程中设置窗口标题,然后在完成后取消设置窗口标题。取消设置标题将恢复为原始值。具体来说,我做了以下事情:
My solution was to set the window title during my script, then unset the window title when I completed. Unsetting the title reverted to the original value. Specifically, I did the following:
有一些终端程序支持它(xterm 有编译时选项,如 RWS 提到的),但大多数终端程序只是缺乏这样的功能,特别是 Terminal.app。
There are some terminal programs that supporting it (xterm has compile time options for that, as mentioned by RWS), but most terminal programs simply lack such feature, including in particular Terminal.app.
是的,这确实是可能的。请参阅
xterm
参考手册(例如此示例)并漫步其中。xterm
甚至为此构建了一个堆栈,因此您不必手动存储标题。Yes, that is possible indeed. See a
xterm
reference manual (like this for example) and wander your way through it.xterm
even has a build in stack for this, so you don't have to store the title manually.