如何设置的Mac OS X 10.6终端分页标题编程? [英] How do I set Mac OS X 10.6 Terminal tab title programmatically?

查看:272
本文介绍了如何设置的Mac OS X 10.6终端分页标题编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我努力学习AppleScript的,因为我想,最终,编程设置选项卡的标题在终端到任何情况下,我目前的工作,应该是一个简单的任务,我几乎得到它好吧,我想。这是我的实验code到目前为止...

I'm trying to learn Applescript as I'd like to, eventually, programmatically set the title of the tab in Terminal to whatever context I'm currently working in. Should be a simple task and I've gotten it almost right I think. This is my experimental code so far...

tell application "Terminal"
    activate
    set frontIndex to index of the first window whose frontmost is true
    tell window frontIndex
        set title displays custom title of selected tab to true
        set custom title of selected tab to "Bazzy"
    end tell
end tell

问题是,当我设置选项卡上的标题,所有其他选项卡的标题也被置1。 然而,如果我右键单击并检查一个选项卡,然后手动设置的标题,标签,当我运行我的code标题不受影响,标题我的遗体手动输入上。就好像在标题会显示自定义标题属性没有被读取或者这个属性没有做什么,我认为它。

The problem is that when I set the tab's title, the title of all other tabs also get set. However, if I right-click and inspect a tab and then set the title manually on that tab, its title is not affected when I run my code and the title I manually typed in remains. It's as though the title displays custom title property is not being read or perhaps this property does not do what I think it does.

我怎么能只有一个选项卡的标题设置为自定义值?

How can I set the title of exactly one tab to a custom value?

推荐答案

你从终端本身执行脚本我可以用一个简单的回声,例如:

I you're executing the script from the Terminal itself you can use a simple echo, e.g.:

回声-n -e\\ 033] 0;达意食谱规则\\ 007

这事件工作,如果你把它放在 $ PS1 ,这样,每次提示渲染的时候被改变。

It event works if you put it inside $PS1 so that it changes each time the prompt is rendered.

来源:<一个href=\"http://stackoverflow.com/questions/6736602/how-do-i-set-mac-os-x-10-6-terminal-tab-title-programmatically\">How做我设置的Mac OS X 10.6终端分页标题编程?

这篇关于如何设置的Mac OS X 10.6终端分页标题编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆