Skip to content

Instantly share code, notes, and snippets.

@avegancafe
Created April 21, 2016 03:56
Show Gist options
  • Select an option

  • Save avegancafe/a8a6e4509026053993efd55f976111d0 to your computer and use it in GitHub Desktop.

Select an option

Save avegancafe/a8a6e4509026053993efd55f976111d0 to your computer and use it in GitHub Desktop.
-- An AppleScript for opening a new window of iTerm
tell application "iTerm" to activate
tell application "System Events"
log processes
if (name in processes) contains "iTerm2" then
tell application "iTerm"
try
-- Tests to see if the Terminal is open
-- This will throw a fatal error if there are no windows in current space
tell the current session of the current window
get id -- will error if there is no window in current space
activate
end tell
on error errmess
-- if there was an error, open new Terminal window
tell the first session to create window with default profile
end try
end tell
else
tell application "iTerm" to activate
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment