I'm tring to write a shortcut script in spark for opening the terminal.

on run {input, parameters}

  tell application "Utilities/Terminal" // tried Utilities:Terminal and Terminal too
  end tell

end run

how can make this work? I'm using 10.10.2 as OSX version.


This is the correct method:

tell application "Terminal"
    if not (exists window 1) then reopen
    -- insert your code here
end tell

EDIT You can open new windows with do script

tell application "Terminal"
    do script ""
end tell
  • this is a better solution. can you check my comment on Matthiue's answer. – Thellimist Feb 5 '15 at 13:51
  • Do you want 1 terminal window or a new window for every time you run the command? – adayzdone Feb 5 '15 at 13:52
  • I want more windows. I want to be able to pass them with cmd` shortcut – Thellimist Feb 5 '15 at 13:53
tell application "Terminal"
  tell application "System Events" to keystroke "n" using {command down}
end tell

Should do the job.

  • 1
    I want it to open multiple times so I tried to put reopen(didnt work) then wrote this: do shell script "open -n /Applications/Utilities/Terminal.app" but the problem is I can't switch tabs with cmd`(below esc) button – Thellimist Feb 5 '15 at 13:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .