Maybe you are tired of opening folders in Visual Studio Code with a terminal or maybe you are just finding ways to speed up your productivity like me! Anyway, you have come to the right place. This guide will teach you how to open folders in VS Code with one simple keyboard shortcut. We will achieve this using "Quick Actions" in macOS.

Creating "Quick Action"

First, open the application called "Automator' that is built into macOS from launchpad or under applications folder .

Automator

This will open a window like this. What we need is "Quick Action", so select the "Quick Action" option and click on Choose".

Actions

You will see the above screen. Now, on the "Actions" panel on the left side, select Library -> Utilities ->  Run Shell Script. Drag and drop the "Run Shell Script" to the right side or simply double-clicking on it.

On the right side screen, we will now configure the options required to setup our action. Fill the options as follows:

Configuring options
Workflow receives current "files or folders" in "Finder.app"

Now, inside the "Run Shell Script" action, set it as follows:

Shell: "/bin/zsh" or "/bin/bash" (depending on what you have installed)
Pass input: "as arguments"

Now, paste the following code into the script area.

open -n -b "com.microsoft.VSCode" --args "$*" 

Save the file as "Open in VS Code".

Now, if you go back to Finder, you can see the quick action we just created by right-clicking on any folder.

Right-click Quick Actions

This perfectly works as it is. But our aim is to make it keyboard accessible. For that, we have a few more steps.

Adding keyboard shortcut to the "Quick Action".

Open macOS System Preferences -> Keyboard -> Shortcuts. Under the services section, find the quick action we just created. It would be the same name as what we gave just earlier, in this case, "Open in VS Code" is the name. now you can give a preferred keyboard shortcut to this action. Voila!!! we are done.

Adding keyboard shortcut

Now click on any folder, use the shortcut to open up Visual Studio Code in that directory

Where is the "Quick Action" saved?

It is under "/Users/{username}/Library/Services". The Library folder is a hidden one, so you can't access it without unhiding the hidden files. You could use the keyboard shortcut "Command + Shift + .(period)" to quickly unhide files and folders.

Quick Action save location

Hope I have made your productivity at least slightly better. Check out other my featured posts in my Blog.