mattintosh note

どこかのエンジニアモドキの備忘録

AppleScript から iTerm にコマンドを送る

よく忘れるのでメモ。launch session で新しいセッション(タブ)を開いて tell last session 内で処理を行う。

set cmd to "cd /tmp"

tell application "iTerm"
    make new terminal
    tell current terminal
        launch session "Default"
        tell last session
            write text cmd
        end tell
    end tell
end tell

一時ファイル作成して open でもいいんだけど。

AppleScript: The Definitive Guide: Scripting and Automating Your Mac

AppleScript: The Definitive Guide: Scripting and Automating Your Mac