5

I've created a service in automator and assigned a shortcut, and it works.

enter image description here

But this doesn't start a new iTerm terminal. It only reveals the already running one

How can I start a new "tab" or a new "iTerm window"?

6

You can change the Action in your Automator-defined service to an AppleScript action:

  • Select Library/Run AppleScript in the Actions window
  • Add the following AppleScript in the created Action and save:
if application "iTerm" is not running then
    activate application "iTerm"
else
    tell application "iTerm"
        create window with default profile
        activate
    end tell
end if

This opens iTerm if it is not running, else it opens a new window. See iTerm documentation for more examples of AppleScript scripting for iTerm.

3

You can use iTerm keyboard shortcut:

  • New Tab: Command ⌘+T
  • New Window: Command ⌘+N
1

You can create an AppleScript that emulates human entry manually. In other words, drag and drop AppleScript and force the application to become the frontmost application and then invoke a contextual menu click as if you clicked it with your mouse. Then re-save it as your service.

And example, but not specific to your application would be:

activate application "ApplicationName"
tell application "System Events"
tell process "ApplicationName"
    keystroke "n" using {command down}
    delay 1
end tell
end tell
0

You can also do this with skhd.

.skhdrc:

ctrl + cmd - t : osascript /Users/user/Library/Scripts/new-iterm-window.scpt

new-iterm-window.scpt:

tell application "iTerm"
    create window with default profile
    activate
end tell

It is a bit faster than via standard services-shortcuts-menubar approach. It works literally in any app, even in one that doesn't have services menu or has that particular shortcut occupied, since skhd intercepts keys first.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .