先日書いたこれのCUI版。iTerm2のAppleScriptにファイル名を渡すだけのワークフローをAutomatorでつくった。Serviceとして登録してFinderから呼び出せるようにした。
iTerm2のApple Scriptはこれをつくったときのを用意して、あとはAppleScriptに変数を渡す方法と、Stringの扱いと、POSIX of
ていうよくわからないのをみつけてできた。
以下のようなAppleScriptを画像のようにAutomatorに入れてサービスをつくればよい。サービスは新規作成でつくれる。保存すれば勝手に登録されて、呼び出すときはFinderでファイルを選択して右クリック->Servicesでいける。
on run {input, parameters}
set fileName to POSIX path of item 1 of input
tell application "iTerm"
activate
set t to (make new terminal)
tell t
set number of columns to 100
set number of rows to 30
set s to (launch session "Default session")
tell s
write text "root " & fileName
write text "_file0->ls()"
end tell
end tell
end tell
return input
end run
Automator内でテストしたいときはこれだけでは動かず、Ask for Finder Items
を前に挿入する。