Created
January 31, 2024 17:15
-
-
Save johnpena/4c8dd956d5b2e7807a68d6343f700e74 to your computer and use it in GitHub Desktop.
Applescript script to open a new tab in iTerm if a window exists, otherwise to open a new window. Useful with Hammerspoon.
This file contains 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
tell application "iTerm" | |
activate | |
-- Check if iTerm is running and has at least one window | |
if (count of windows) is greater than 0 then | |
-- iTerm is running and has at least one window, so create a new tab | |
tell current window | |
create tab with default profile | |
end tell | |
else | |
-- iTerm is running but has no windows, so create a new window | |
create window with default profile | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment