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”.
- Open a new document in automator. Choose Quick Action.
2. Select the option “no input” next to “Workflow receives”.
3. From the Utilities action menu, double click “Run Shell Script”
4. Enter the command you want to run (see section below for examples)
5. Save quick action with a unique name e.g. “Open New Text File”
At this point, you should test your quick action by clicking the “Run” arrow in the top right of the automator window.
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).
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"
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 ;)