Created
April 21, 2016 03:56
-
-
Save avegancafe/a8a6e4509026053993efd55f976111d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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