{"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.

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}\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!

\"screenshot\"

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.

\"screenshot\"

What about the existing iTerm2 feature?

\"screenshot\"

This feature creates a global slide-down window, similar to guake and other tools. What I needed was an actual separate window, or more.

","published_at":"2018-09-17T23:06:59.000+03:00","slug":"how-to-set-global-shortcut-open-new-iterm2-window","tags":[],"plaintext":"When I used to use i3wm [https://i3wm.org/] on Linux, I had command+enter open\na new terminal window. I think that was my most-used shortcut. I've been running\nmacOS for a few years now and haven't bothered to set up a similar shortcut\nuntil recently.\n\nOk, so how does it work?\nThe global shortcut is set using FastScripts\n[https://red-sweater.com/fastscripts/]. It runs an AppleScript script that\nstarts iTerm2 if it's not running, or instructs it to open a new window if it\nis.\n\nHow do I set it up?\nOpen Automator.app and create a new Workflow. Search for Run AppleScript in the\nlist and drag it over to the workflow pane on the right. In it, paste the\nfollowing:\n\non 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\n\nI found this snippet somewhere on the internet, but I forget where. Sorry for\nnot crediting the author!\n\nSave the workflow somewhere accessible to you. Click on FastScript's menubar\nicon → FastScripts → Open Scripts Folder → /Users/you/Library/Scripts. Move the\nworkflow file to that directory. The workflow should now be accessible through\nthe FastScripts menubar menu.\n\nTo set a global shortcut, open FastScripts' preferences window and go to the\nScript Shortcuts tab.\n\nWhat about the existing iTerm2 feature?\nThis feature creates a global slide-down window, similar to guake and other\ntools. What I needed was an actual separate window, or more.","meta_description":null}}]}},"pageContext":{"slug":"how-to-set-global-shortcut-open-new-iterm2-window","prev":"securing-internal-services-behind-oauth2-with-caddy","next":"preventing-loading-progress-bar-flashes-with-vue"}},"staticQueryHashes":["3649515864"]}