Skip to content

Instantly share code, notes, and snippets.

@jerith
Created November 20, 2012 20:04
Show Gist options
  • Save jerith/4120666 to your computer and use it in GitHub Desktop.
Save jerith/4120666 to your computer and use it in GitHub Desktop.
-----------------------------------------------------------------------------
-- This script creates a new terminal window.
--
-- If you disable "When switching to an application, switch to a space with
-- open windows" in the Spaces preferences, the new terminal window will
-- appear on the current workspace.
--
-- Terminal.app creates a new window on startup, so we need to check if it's
-- already running and not create an extra window in that case.
-----------------------------------------------------------------------------
-- if application "Terminal" is running then
-- activate application "Terminal"
-- tell application "System Events"
-- tell process "Terminal"
-- click menu item "New Window" of menu "Shell" of menu bar 1
-- end tell
-- end tell
-- else
-- -- Starting Terminal creates a new window
-- activate application "Terminal"
-- end if
-----------------------------------------------------------------------------
-- Pretty much as above, except using iTerm.
-----------------------------------------------------------------------------
if application "iTerm" is running then
tell application "iTerm"
set myterm to (make new terminal)
tell myterm
launch session "Default Session"
end tell
activate current session
end tell
else
activate application "iTerm"
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment