我正在尝试编写一个可以在终端的多个选项卡中运行多个命令的脚本。 我发现了很多关于它的信息,但它并不像我想要的那样工作。所以我可能需要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
但我没想出如何“混合”它们。有什么想法吗?
答案 0 :(得分: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