Terminal.appでは以下のように引数を与えることが可能.

  • ワーキングディレクトリを指定して起動する

      open -a "Terminal" ~/Desktop
  • 実行ファイルを指定して起動

      open -a "Terminal"" ~/test.sh

しかしGnome-Terminalのように直接コマンドを引数に与えることができない.シェルスクリプトやVimなどでどうしてもコマンドを与えたい場合は次のような方法がある.

tmpファイルを経由する

echo "echo 'Hello'" > .tmp/tmp; chmod +x .tmp/tmp; open -a "Terminal" .tmp/tmp

Applescriptを経由する

on run argv
    -- 引数がひとつのみのとき実行する
    if length of argv is 1 then
        set launch_command to the first item of argv
        tell application "Terminal"
            do script launch_command
            activate
        end tell        
    end if
end run

上のコードをOpenTerminalWithCommand.scptとして保存すれば以下のようにして利用可能.

osascript OpenTerminalWithCommand.scpt "echo Hi"