How do I run an iTerm session from the command line, passing in the command which is to be executed in the iTerm window?
The xterm analog is -e
, i.e.
xterm -e sleep 10
I had found the official documentation, but hadn't thought to wrap the Applescript up with osascript like SushiHangover- very nice. His answer didn't work for me, probably because I'm using the latest beta 3.0 version, so here's one that does work (and also simplifies a bit).
#!/bin/bash
osascript - "$@" <<EOF
on run argv
tell application "iTerm"
activate
set new_term to (create window with default profile)
tell new_term
tell the current session
repeat with arg in argv
write text arg
end repeat
end tell
end tell
end tell
end run
EOF