macos - 在单个窗口中从 AppleScript 执行终端命令

标签 macos terminal applescript

我想从 AppleScript 执行一些终端命令。我正在 for 循环中执行此操作。问题是,对于每个循环,我都会在终端中得到一个新窗口。但我想在一个窗口中执行所有命令。我怎样才能做到这一点?

我的代码是这样的,

repeat with i from 1 to 5

    tell application "Terminal"
        activate
        set currentTab to do script "date"
    end tell
end repeat

最佳答案

尝试:

set currentTab to do script "date" in window 1

关于macos - 在单个窗口中从 AppleScript 执行终端命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13251962/

相关文章:

javascript - 从另一个 JSAppleScript 运行另一个 JS AppleScript 时出现权限错误

linux - Bash 从包含空格的路径中删除文件

c - 16 KB 由 OS X 上的 getc 和 fprintf 分配

使用applescript zip 文件夹

git - 是否可以从终端而不是网站在 github 中创建 pull 请求

macos - 通过 iTerm2 使用 Powerlevel10k 更改 Visual Studio 代码中的终端

javascript - getInfoByClass 的简单错误?

objective-c - 如何使用cocoa获取MAC OS ISO 639-2格式的系统语言?

c++ - 在哪里可以找到带有 -static 选项的预编译 Qt for macOS?

ruby-on-rails - 在 postgresql gem 上 bundle 安装失败。 (是的,已安装 postgres)