applescript - iTerm applescript 在两个单独的垂直 Pane 中写入

标签 applescript iterm2

我正在尝试编写一个苹果脚本: - 打开一个新窗口 - 更改目录 - 将 Pane 垂直拆分到同一目录中 - 在左 Pane 中写入文本 - 在右 Pane 中写入文本

如果可能的话,同时执行两个 Pane 。

我能得到的最接近的是做类似的事情,但打开两个单独的窗口。像这样:

    tell application "iTerm"
       set myterm to create window with default profile
       tell myterm
          activate current session
          launch session "Default Session"
          tell the current session
             write text "cd ~/Desktop"
             write text "xcodebuild clean -workspace -scheme WelcomeScreenTests -sdk iphonesimulator -destination 'platform=iOS Simulator,id=476E9E8C-8248-4EF6-8054-67900D603E83'  test | xcpretty"
          end tell
    end tell
    set myterm to create window with default profile
    tell myterm
       activate current session
       launch session "Default Session"
       tell the current session
          write text "cd ~/Desktop"
          write text "xcodebuild clean -workspace -scheme WelcomeScreenTests2 -sdk iphonesimulator -destination 'platform=iOS Simulator,id=F3DEA448-147B-4DDB-AD83-16D18BA1A87F' test | xcpretty"
       end tell
    end tell

任何帮助都会非常感谢

最佳答案

这是可能的。

tell application "iTerm"
    set myterm to create window with default profile
    tell myterm
        activate current session
        launch session "Default Session"
        tell the current session
            write text "cd ~/Desktop"

            -- use 'without newline' to write without executing the command
            write text "xcodebuild clean -workspace -scheme WelcomeScreenTests -sdk iphonesimulator -destination 'platform=iOS Simulator,id=476E9E8C-8248-4EF6-8054-67900D603E83'  test | xcpretty" without newline
            tell (split vertically with same profile)
                write text "cd ~/Desktop"

                -- use 'without newline' to write without executing the command
                write text "xcodebuild clean -workspace -scheme WelcomeScreenTests2 -sdk iphonesimulator -destination 'platform=iOS Simulator,id=F3DEA448-147B-4DDB-AD83-16D18BA1A87F' test | xcpretty" without newline
            end tell
        end tell
        write (sessions of current tab) text linefeed -- append newline to the last line of each session to executes both panes simultaneously.
    end tell
end tell

关于applescript - iTerm applescript 在两个单独的垂直 Pane 中写入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46195919/

相关文章:

Applescript - 如何迭代轨道

iTerm2 v3 将制表符转换为粘贴时的空格

heroku - 如何查看没有时间戳/额外信息的 Heroku 日志?

javascript - jxa - 在 JavaScript 中获取 NSAttributedString 字体指标以实现自动化

events - AppleScript 事件监听

objective-c - 无法解析 NSAppleScript 方法executeAndReturnError返回的结果

ios - 在 Xcode 中构建阶段后运行 Applescript

macos - 如何在iterm2上反转配色方案?

zsh - 使用 zsh 自动完成大型/.ssh/config 文件很慢

macos - 让 Vim Solarized 在 iTerm 上工作