When I used to use i3wm on Linux, I had command
+enter
open a new terminal window. I think that was my most-used shortcut. I've been running macOS for a few years now and haven't bothered to set up a similar shortcut until recently.
Ok, so how does it work?
The global shortcut is set using FastScripts. It runs an AppleScript script that starts iTerm2 if it's not running, or instructs it to open a new window if it is.
How do I set it up?
Open Automator.app and create a new Workflow. Search for Run AppleScript in the list and drag it over to the workflow pane on the right. In it, paste the following:
on run {input, parameters}
if application "iTerm" is not running then
activate application "iTerm"
else
tell application "iTerm"
create window with default profile
activate
end tell
end if
return input
end run
I found this snippet somewhere on the internet, but I forget where. Sorry for not crediting the author!
Save the workflow somewhere accessible to you. Click on FastScript's menubar icon → FastScripts → Open Scripts Folder → /Users/you/Library/Scripts
. Move the workflow file to that directory. The workflow should now be accessible through the FastScripts menubar menu.
To set a global shortcut, open FastScripts' preferences window and go to the Script Shortcuts tab.
What about the existing iTerm2 feature?
This feature creates a global slide-down window, similar to guake
and other tools. What I needed was an actual separate window, or more.