9

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
    reopen
    activate
  end tell

end run

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

2 Answers 2

16

This is the correct method:

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

EDIT You can open new windows with do script

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

Should do the job.

1
  • 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, 2015 at 13:47

You must log in to answer this question.

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