0

我正在尝试在 OSX 中选择某个终端选项卡并向其发送击键。但是 OSX 10.8.4 中的终端似乎没有为选项卡的自定义标题存储“终端”以外的任何内容,即使您使用检查器设置了自定义标题也是如此。有任何想法吗?这是我想用来选择正确选项卡的代码:

tell application "Terminal"
  set allWindows to number of windows

  repeat with i from 1 to allWindows
    set allTabs to number of tabs of window i
    repeat with j from 1 to allTabs
      if custom title of tab j of window i contains "blah" then
        set frontmost of window i to true
        set selected of tab j of window i to true
      end if
    end repeat
  end repeat
end tell 
4

2 回答 2

0

确保以这种方式设置选项卡名称:

tell "application" "Terminal"
# ...
  set the_tab to tab 1 of the front window -- replace with your tab selector
  tell settings set "Basic"
      set custom title of the_tab to "My Tab Name"
  end tell
# ...
end tell

您应该能够检索选项卡名称:

tell "application" "Terminal"
     set the_name to custom title of the_tab as string
end tell

在 OSX 10.8.4 上为我工作

于 2013-10-12T03:23:34.887 回答
0

我正在使用旧版本的 OSX,所以我无法复制您的问题(您的代码对我来说很好),但也许可以尝试:

if ((custom title of (current settings of (tab j of (window i)))) as string) contains "blah" then
于 2013-07-22T17:39:19.347 回答