ahaldorsen.no

Opening specific folders in a text editor quickly on Mac OS

Screenshot of Spotlight on Mac OS. User has typed in ,notes

I wanted a shortcut to open specified folders (for notes, development projects, etc.) in specified programs (a plain text editor, an IDE, etc), and I think I found a solution that works well.

Step 1: Create a script with the Script Editor

The script is really simple. Follow this structure:

do shell script "open -a '[Your preferred text editor]' '[Path to the folder you want to open in the text editor]'"

Example:

do shell script "open -a 'Zed' '/Users/ahaldorsen/notes/'"

Step 2: Save the script as an app

Screenshot of Script Editor on Mac Os while exporting a script as an app

Step 3: Try the new shortcut

Open Spotlight (Apple’s search functionality) with Cmd + Spacebar, type ,notes and press Enter. Your text editor should now open, loaded with the specified folder.

Step 4: Repeat the process for more folders

As a developer I have multiple text based projects that I work on in different text editors and IDEs. I’ve added shortcuts like this for most of them. For example:

As a bonus, I can get a list of the shortcuts by opening Spotlight and typing , because the filenames all start with a comma.