在终端的新选项卡运行命令

问题描述 投票:4回答:1

我试着写,可以在终端几个标签运行几个命令的脚本。我发现了很多关于它的信息的,但我希望它这是行不通的。所以,我可能需要的AppleScript。

•此代码运行在一个新窗口中的命令:

tell app "Terminal"
   do script "echo hello"
end tell

•这一个打开一个新标签

tell application "Terminal"
  activate
  tell application "System Events"
    keystroke "t" using {command down}
  end tell
end tell

但我没有想出如何“混”出来。任何想法 ?

macos shell command-line terminal applescript
1个回答
5
投票
tell application "Terminal"
    activate
    tell application "System Events"
        keystroke "t" using {command down}
    end tell
    do script "echo hello" in selected tab of the front window
end tell
© www.soinside.com 2019 - 2024. All rights reserved.