Skip to content

Instantly share code, notes, and snippets.

@novemberborn
Created June 26, 2011 18:00
Show Gist options
  • Save novemberborn/1047803 to your computer and use it in GitHub Desktop.
Save novemberborn/1047803 to your computer and use it in GitHub Desktop.
Focus the terminal window open in the current space, or open a new one.
tell application "Terminal"
activate
set hasWindow to false
try
repeat with theWindow in windows
if (frontmost of theWindow) then
set hasWindow to true
end if
end repeat
end try
if (hasWindow is false) then
do script
end if
return hasWindow
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment