好的,事情是这样的。我希望每个工作都有不同风格的终端窗口。每一个终端窗口将连接到不同的工作,例如,一个将通过ssh连接到一个站点,另一个窗口连接到其他地方等。
所以我想这可以通过一些Applescript来实现?
关键是编写一些Applescript脚本来打开不同的终端窗口。然后将每个脚本添加到快捷方式中。
有任何想法吗?
谢谢 :)
好的,事情是这样的。我希望每个工作都有不同风格的终端窗口。每一个终端窗口将连接到不同的工作,例如,一个将通过ssh连接到一个站点,另一个窗口连接到其他地方等。
所以我想这可以通过一些Applescript来实现?
关键是编写一些Applescript脚本来打开不同的终端窗口。然后将每个脚本添加到快捷方式中。
有任何想法吗?
谢谢 :)
tell application "System Events" to tell process "Terminal" to click menu bar 1's menu bar item "Shell"'s menu 1's menu item "New Window"'s menu 1's menu item "Grass"
tell application "Terminal"
set win to do script
set win's current settings to settings set "Basic"
end tell
tell application "System Events" to tell menu 1 of menu item 1 of menu 1 of menu bar item 3 of menu bar 1 of application process "Terminal" to click menu item "Grass"
(虽然这依赖于位置,但在这种特定情况下,可以合理地假设它们不会改变;请注意,设置名称不本地化)。第二个解决方案的注意事项:在选项卡创建之后应用设置可以工作,但仅适用于视觉属性,而不是行为属性,例如“首选项>设置>Shell”中的“When the shell exits:”设置。 - mklement0如何在终端中设置窗口组?
打开所有所需的终端窗口 --> Shell --> 显示检查器。在设置中,您可以更改每个终端窗口的主题。
窗口 --> 另存为窗口组
在首选项中将启动选项设置为显示该组。
http://img18.imageshack.us/img18/9681/screenshot20111018at110.png http://img542.imageshack.us/img542/9681/screenshot20111018at110.png
如果您想使用Applescript来设置窗口的主题,首先需要使用以下Applescript获取所有主题的ID:set a to {}
tell application "Terminal"
repeat with i from 1 to count settings set
set temp to {settings set i's name, settings set i's id}
set end of a to temp
end repeat
a
end tell
tell application "Terminal"
set a to do script "" -- creates new window
set a's current settings to (settings set id <one of the id #>)
end tell
set a's current settings to settings set "Grass"
。此外,尽管在选项卡创建之后应用设置是有效的,但它仅针对视觉属性而非行为属性,例如“首选项>设置>Shell”中的“When the shell exits:”设置。不幸的是,终端的AppleScript支持不支持使用单个命令创建具有特定设置的窗口(或选项卡)。 - mklement0