This is the official method from Microsoft and allows you to open a folder in VS Code directly from your terminal.
-
Launch VS Code.
-
Open the Command Palette using the shortcut
Cmd + Shift + P. -
Type shell command into the search bar.
-
Select and run the command:
Shell Command: Install 'code' command in PATH -
Restart your terminal application(s) for the change to take effect.
-
Once installed, you can navigate to any project folder in your terminal and type:
code .(Don’t forget the dot) to open that folder in Visual Studio Code.
For a direct right-click menu option in Finder, you can create an Automator Quick Action.
-
Open Automator (found in your Applications folder or via Spotlight search).
-
Select File > New, and choose Quick Action as the document type.
-
At the top of the workflow pane:
- Set Workflow receives current to folders in any application
(or just Finder for a more specific setup).
- Set Workflow receives current to folders in any application
-
In the actions library on the left, search for Run Shell Script and drag it into the main workflow area.
-
In the Run Shell Script action:
- Set Shell to
/bin/bashor/bin/zsh. - Set Pass input to as arguments.
- Set Shell to
-
Replace the default script with the following code:
for f in "$@" do open -a "Visual Studio Code" "$f" done
-
Save your Quick Action with a descriptive name, such as Open in Code.
-
Now, you can right-click on any folder in Finder, select Quick Actions, and choose Open in Code to open the folder in Visual Studio Code.