Jen*_*ens 5 macos terminal applescript osx-snow-leopard
我正在努力学习Applescript,最终,以编程方式将终端中的选项卡标题设置为我目前正在使用的任何上下文.应该是一个简单的任务,我认为它几乎是正确的我认为.这是我到目前为止的实验代码......
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
Run Code Online (Sandbox Code Playgroud)
问题是当我设置标签的标题时,所有其他标签的标题也会被设置.但是,如果我右键单击并检查选项卡,然后在该选项卡上手动设置标题,则在运行我的代码时,其标题不会受到影响,并且我手动键入的标题仍然存在.就好像title displays custom title没有阅读该属性,或者这个属性可能不会像我想的那样做.
如何将一个选项卡的标题设置为自定义值?
我是你从终端本身执行脚本你可以使用一个简单的echo,例如:
echo -n -e "\033]0;Tech-Recipes rules\007"
如果您将其放入内部$PS1以使其在每次呈现提示时都更改,则此事件有效.
来源:如何以编程方式设置Mac OS X 10.6终端选项卡标题?
该属性并不像您想象的那样。根据以下代码,将自定义标题设置为一个选项卡适用于所有窗口中的所有选项卡:
\n\ntell application "Terminal"\n tell window 1\n set title displays custom title of tab 1 to true\n set custom title of selected tab to "foo"\n end tell\n tell window 2\n set title displays custom title of tab 2 to true\n set custom title of selected tab to "bar"\n end tell\nend tell\n--> RESULT: All tabs in all windows show "bar"\nRun Code Online (Sandbox Code Playgroud)\n\n我想知道它是否与环境 \xe2\x80\x94 相关的标题有关,即 , bash, csh, zsh\ kshxe2\x80\x94 而不是与各个选项卡有关。即使我退出终端并返回,“bar”仍然显示无处不在。我坦率地承认,我对 CL 接口的工作原理了解不够,无法确定。
同时,如果您正在学习 Applescript,我建议您使用一些不那么奇怪的东西来学习它,比如 Finder 之类的。与使用 Applescript 的终端相比,这里可以完成更多有用的事情。
\n| 归档时间: |
|
| 查看次数: |
6359 次 |
| 最近记录: |