Try:
on alfred_script(q)
tell application "Terminal"
if not (exists window 1) then reopen
activate
do script q in window 1
end tell
end alfred_script
Question
What changes do I make to make it so that it only opens a window if Terminal isn't already running but otherwise, enters the command in the open window? I'm thinking control flow, conditional jawn. I'm not sure how to write it out though.
Thanks, TJ
The script is as follows:
on alfred_script(q)
tell application "Terminal"
activate
do script q
end tell
end alfred_script
Solution
Try:
on alfred_script(q)
tell application "Terminal"
if not (exists window 1) then reopen
activate
do script q in window 1
end tell
end alfred_script
OTHER TIPS
Check this: https://github.com/miromannino/alfred-new-terminal-window
It opens a new Terminal/iTerm window in the current space. Holding the alt key, the new window is also opened opened in the current frontmost Finder folder.
It is really faster compared to others, really important for me since I use the terminal for almost everything! :)
Hope it helps!