【发布时间】:2016-04-08 18:20:01
【问题描述】:
基本上,我想在打开新窗口而不是新选项卡时更改 bash 的主题,然后让窗口的选项卡共享相同的主题;而单独窗口的主题是随机确定的。
经过一番挖掘,我发现了一个applescript,它设置了终端窗口当前选项卡的主题。我创建了一个
/usr/local/terminal-color.scpt 为:
on run argv
tell application "Terminal" to set current settings of selected tab of front window to some settings set
end run
我在我的 bash 个人资料中添加了以下语句:
osascript /usr/local/terminal-color.scpt
当然,现在这个脚本会与 bash 的每个新实例一起运行。我无法从 bash_profile 对此做任何事情。但是,我应该能够将新窗口或新选项卡与 applescript 本身区分开来。因此,我正在寻找一个 if 语句,它可以让脚本仅在创建新窗口时运行。比如:
on run argv
if index of selected tab is 0
tell application "Terminal" ....
end if
end run
但是查看终端应用程序的 applescript 文档和脚本字典,我无法弄清楚如何实现这一点。请帮忙
更新
我尝试如下编辑脚本:
set tabNum to number of tabs of front window
if tabNum = 1 then
tell app ...
这也不会产生错误tabs of window 1 doesn’t understand the “count” message
【问题讨论】:
标签: bash terminal applescript osx-elcapitan