New-Window Shortcuts for MacOS Apps

If you’re like me then you try to avoid using the mouse whenever possible. This post will help with that.

The Action to Automate

My “normal” workflow involves opening new application windows pretty frequently.

For example, I might open a new terminal window to start working on a project, or I might open a new text editor window to jot down a note.

How this goes is that I need to hover my cursor over the icon in my dock, right click to pull up the options, and scroll up to the “New window” option

Lame right? And I’ve probably done this thousands of times in the last few years.

In the section below I show how to map this sort of behaviour to keyboard shortcut by using Automator to trigger shell scripts.

Solution: Automator + Keyboard System Preferences

We are going to create a “Quick Action” using automator and then setup a keyboard shortcut to trigger it with “App Shortcuts”.

  1. Open a new document in automator. Choose Quick Action.
Image for post
Image for post

2. Select the option “no input” next to “Workflow receives”.

Image for post
Image for post

3. From the Utilities action menu, double click “Run Shell Script”

Image for post
Image for post

4. Enter the command you want to run (see section below for examples)

Image for post
Image for post

5. Save quick action with a unique name e.g. “Open New Text File”

Image for post
Image for post

At this point, you should test your quick action by clicking the “Run” arrow in the top right of the automator window.

Image for post
Image for post

6. Go to Keyboard settings in System Preferences. Click on “App Shortcuts” from the left menu bar and then click on the “+” symbol to add a new one.

Enter the unique name of your quick action and assign it a keyboard shortcut (try to pick something that doesn’t conflict with other app shortcuts).

Image for post
Image for post

Test your new shortcut by inputting your assigned pattern. If it doesn’t work then try moving to a different window first (away from system preferences). If it sill doesn’t work, then try a different combination of buttons for the keyboard shortcut in step 6.

Shell Commands to Open New Windows

This solution can extend to any application (or ad-hoc functionality) so long as there is a shell command that can accomplish it. This can even include running AppleScript commands.

Below I write out some shell commands that I’ve used to automate things. You can copy and paste these in step 4.

Open new text file with default editor

open -t ~/Downloads

Open new terminal window

osascript -e 'tell app "Terminal" to do script "cd ~/ && echo 🚀"'

Open new chrome window

open -na "Google Chrome"

Conclusion

Thanks for reading! I hope you were able to get your own shortcuts working.

Feel free to post your own shell commands in the comments and I will add them to the post above.

Now get back to your projects! They are missing you ;)

https://alexgalea.ca/

Written by

Python Data Engineer, MSc. Physics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store