{"componentChunkName":"component---src-templates-blog-post-js","path":"/blog/how-to-set-global-shortcut-open-new-iterm2-window","result":{"data":{"allGhostPost":{"edges":[{"node":{"title":"How to Set a Global Shortcut to Open a New iTerm2 Window","html":"
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.
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.
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}\n\tif application \"iTerm\" is not running then\n\t\tactivate application \"iTerm\"\n\telse\n\t\ttell application \"iTerm\"\n\t\t\tcreate window with default profile\n\t\t\tactivate\n\t\tend tell\n\tend if\n\t\n\treturn input\nend 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.
This feature creates a global slide-down window, similar to guake
and other tools. What I needed was an actual separate window, or more.