Skip to content

Instantly share code, notes, and snippets.

@johnpena
Created January 31, 2024 17:15
Show Gist options
  • Save johnpena/4c8dd956d5b2e7807a68d6343f700e74 to your computer and use it in GitHub Desktop.
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.
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