How should I start a new iTerm terminal with shortcut?
I've created a service in automator and assigned a shortcut, and it works.
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"?
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.
You can use iTerm keyboard shortcut:
- New Tab: Command ⌘+T
- New Window: Command ⌘+N
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.