Skip to content

Instantly share code, notes, and snippets.

@nuada
Created May 18, 2016 11:04
Show Gist options
  • Save nuada/204e8082280328654ca651f1730a1aa7 to your computer and use it in GitHub Desktop.
Save nuada/204e8082280328654ca651f1730a1aa7 to your computer and use it in GitHub Desktop.
Execute command in new Terminal window on Mac OS X using Applescript.
#!/bin/sh
echo 'on run
-- check if Terminal is already running
tell application "System Events"
set isRunning to (exists process "Terminal")
end tell
tell application "Terminal"
-- if Terminal is running create new window
if isRunning then do script ""
activate
-- some command to execute
do script "ls /" in front window
end tell
end run' | osascript -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment