On my windows pc, I would just double click a folder and click "Open in VS Code" to a open a folder, which saved time for me when looking through lots of code online. With Mac, however, I do not have this option. I have to directly open vscode and click "Open" to open a new folder. How do I directly open a file in vscode through finder in macOS?
-
It's worth noting that being able to directly open a file in vscode through finder in macOS already exists - what's missing is the ability to open a folder in vscode from finder, and that's what the answers are addressing. – Shiraz Oct 04 '22 at 13:21
12 Answers
2023 Update - Use Native Method
- Open the Command Palette (
Cmd+Shift+P
) and typeshell command
to find the Shell Command: Install 'code' command in PATH command.
- Restart all terminal sessions for the new $PATH value to take effect.
You'll be able to type code .
in any folder to start editing files in that folder.
If you want to do it in Finder, you can write an Automator script to do it (it's easier than it sounds, AND shows you the power of the OS).
Launch Automator
Create New Document
Add the Action... (New Method - 10.13+)
- Workflow receives current files or folders from Finder.
- Add a new "Open Finder Items" action to the workflow. (drag the "Open Finder Items" object, highlighted in the screenshot, to the empty window on the right)
- Select "Visual Studio Code" from the list.
Add the Action... (Old Method)
- Workflow receives current files or folders from Finder.
- Add a new Run Shell Script action to the workflow. (drag the "Run Shell Script" object, highlighted in the screenshot, to the empty window on the right)
Configure the Workflow (Old Method)
- Set the Pass Input to be as arguments
- Paste the following in the input box:
open -n -b "com.microsoft.VSCode" --args "$*"
Save the action using a name like Open in Visual Studio Code.
You may now right-click on the folder and find your newly created task under Quick Actions.

- 7,629
- 2
- 26
- 40
-
-
2There is. That's the "Image" icon in the second screenshot. Select from a list or add your own. – jnovack Sep 25 '20 at 19:46
-
2And for VSCodium it's: `open -n -b "com.visualstudio.code.oss" --args "$*"` – cyberwombat Nov 11 '20 at 14:36
-
2For VS Code Insiders use the Application Bundle Identifier `com.microsoft.VSCodeInsiders` (full command: `open -n -b "com.microsoft.VSCodeInsiders" --args "$*"`) – Emil Devantie Brockdorff Aug 11 '21 at 11:38
-
2Thanks a lot for the solution and introducing to one of the most underrated feature on mac, Automator. – Jatin Garg Sep 10 '21 at 06:17
-
I followed these steps, but when I click "Open in Visual .." it throws an error: The action “Run Shell Script” encountered an error: “The application /Users/saadzafar/Downloads/Visual Studio Code.app cannot be opened, error=Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"” – Saad Zafar Oct 13 '21 at 13:09
-
15vs code is opening but its blank not opening the corresponding folder – PRAJIN PRAKASH Oct 29 '21 at 08:28
-
3
-
6The accepted answer doesn't work on Mac OS Monterey. You can force it to work by locating the workflow in ~/Library/Services (note ~/Library may be hidden), opening it in the new Shortcuts app and giving it permission to run scripts. Otherwise, you can create it from scratch in the Shortcuts app as described by @gluedpixel. – John Henry Nov 27 '21 at 00:29
-
Great answer! Pro tip: if you've changed your default terminal away from zsh you will want to set it back to zsh for this to work. I'm sure there's a way to get it to run with any terminal, but probably not worth exploring when zsh works just fine. – Raydot Jan 08 '22 at 21:54
-
1Under "image" for the workflow, you can even select "own" (or "custom" - not sure, since I have no english language), and navigate to "Visual Studio Code.app" and choose it - that way you even have the VS Code App Icon as an Image for the quick action (at least on macOS Monterey)! – Steffen Funke Jan 16 '22 at 17:29
-
8If your VS Code is opening blank make sure in your **Run Shell Script** section the option `Pass input` is set `as arguments`. – Gaurav Kispotta Apr 01 '22 at 08:50
-
2Hearing some complaints down here about this method not working on new OSX versions. If that's your case, try the method suggested by @AD_Progress down below. Works well for me on Monteray and is definitely a cleaner solution. – Apekshik Panigrahi Apr 30 '22 at 22:23
-
I also got "Operation not permitted" and solved it following [this page](https://brianli.com/how-to-fix-automator-operation-not-permitted-error-in-macos-catalina/), which is to manually grant full disk access to Finder. Go to System Preferences > Security & Privacy > Privacy. Basically, scroll down on the left column and click on Full Disk Access. Click on the + button and add Finder. – Nadjib Mami Aug 06 '22 at 19:07
-
Opened an empty vs code window, but missed setting "Pass input" as "as arguments", seems it defaults as stdin – Devishankar Jan 26 '23 at 22:35
-
-
1
-
The simplest solution is to create a Quick Action with Open Finder Items: This way you don't need a shell script that might break with an OS update or VS Code update
- Launch Automator and select Quick Action or File > New > Quick Action If Automator is already open.
Set Quick Action receives selected to files or folders and in to Finder.
Choose an Image (icon) select Choose.. and double click Visual Studio Code in the window that pops up, this will set your quick action icon to the same as VS Code
On the left-hand side where you see all the available items to add to your automation go into the search bar and type open, next choose Open Finder Items (you can either double click it or drag it to your workflow), Choose open with as Other.. select Visual Studio Code.
- Finally, just hit CMD+S to save and name it Open in VSCode

- 4,190
- 1
- 14
- 33
-
15
-
2
-
2i think this should be accepted answer because it's more clear and working in present time. – Amit Singh Aug 08 '22 at 02:47
-
3
-
1@ZeeshanAhmadKhalil There could be a tickbox to untick Use recommended – AD Progress Oct 10 '22 at 15:32
-
1I like this versus using the Shortcuts app because you get the VSCode icon. – GollyJer Nov 24 '22 at 01:07
-
1
-
1
-
1
-
1
-
1
-
3@ZeeshanAhmadKhalil just had the same problem. Didn't find any info on it other than the comments here. But I tried something kinda stupid and it just worked. When you are in the selection screen for the "Other..." app, just drag VS Code (or any other app) from the selection pane onto the selection menu in Automator XD. – Ichixgo Feb 02 '23 at 17:02
-
2@ZeeshanAhmadKhalil You need to register VS Code as an app by dragging it's package file (it's probably in Downloads) to Applications. After that, you'll see it in app list – astef Feb 24 '23 at 20:41
-
1
Well you need to understand. macOS has different ways to do things than windows and initially it might be a challenge. For starters you start to make use of Terminal. its beautiful.
Now answering your question.
Open your VS code and then, press CMD + SHIFT + P
, type shell command
and select Install code command
in path. Afterwards, navigate to any project from the terminal and type code .
from the directory to launch the project using VS Code.

- 1,326
- 2
- 8
- 17
-
3
-
1
-
19
-
@distante because op needs to understand mac is different than windows. and should learn how to use mac rather making mac working as windows. – Jitesh Dhamaniya Sep 06 '21 at 05:29
-
7@JiteshDhamaniya Mac also has `open with`. It is not a windows-only feature. – distante Sep 06 '21 at 09:07
-
-
4Downgrading because it doesn't answer the OP request, and requires going to a terminal window in order to open a folder that is currently visible in Finder. It doesn't make sense to go from a UI (Finder) to a command prompt (Terminal) to then launch a UI application (VS Code). – Shiraz Oct 04 '22 at 13:18
Using the new shortcuts app.
Or create it by yourself

- 292
- 3
- 6
-
3make sure to also enable it in context menu items: quick actions -> customize -> tick – GorvGoyl Jan 30 '22 at 13:24
-
Not a request of the OP, but I added a Keyboard Shortcut for this using Preferences > Keyboard > Shortcuts. – RonH Apr 29 '22 at 14:26
There are some ways suggested here in the VS Code GitHub Issues tracker, but I would go with the first option of dragging the folder onto the app icon if you have VS Code icon in your dock!
If you really want to be able to do so from a right click, then this repository has a workflow solution. https://github.com/Sankra/OpenFolderInVSCode

- 373
- 1
- 6
-
1here is updated cloned repo to allow opening of both files/folders in VSCode via finder shortcut: https://github.com/Pr0to7yp3/OpenInVSCode – scottydelta Feb 28 '21 at 22:24
-
Thanks, "dragging the folder onto the app icon" is probably the fastest way to open a folder in VS Code and pretty easy. – Akash Kumar Seth May 20 '21 at 13:48
-
This is a very underrated answer, as this works particularly very easily in this usecase. – Aswin Prasad Jul 14 '21 at 03:13
-
-
Nice, the OpenFolderInVSCode workflow has the benefit of creating a new window in VSCode – a lot of workflow solutions open the folder in the existing window. – And Finally Jul 28 '23 at 15:59
I've actually managed to have it as an icon you can just add to the Finder window as such:
The script will allow you to open the current folder path in VSCode.
The steps to do so are:
- Create a new Application with Automator
- Select the "Run shell script" from the menu and drag it to the editor
- Paste the following small script to the text area:
finderPath=`osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)'`
open -n -b "com.microsoft.VSCode" --args "$finderPath"
- Save the Application to the Applications folder
- Right click the app and drag and drop your desired VSCode icon to the blank area to the left of the name and close the Get Info window
- Press and hold the
Command
key and drag the Application to an empty space in the Finder title row like in the picture - Test that it works by pressing on the icon. VSCode should now open with the content of the current folder in the navigation bar

- 81
- 1
- 2
Found a way to achieve a 'Quick Action' that met my needs using the following steps using MacOS' Shortcuts app (No Automator needed):
if you are looking for screenshots as well, I wrote a small Notion page
- Open the ‘Shortcuts’ app on your Mac
- On the Left Pane, navigate to ‘Quick Actions’
- On the top bar, press the ➕ button to add New Shortcut.
- Click on ‘Any’ and change to ‘Files and Folders’ by selecting only those from the dropdown that appears on clicking the ‘Any’ field.
- Click on ‘Action Library’ on the right pane and search for ‘shell’. Drag and drop the ‘Run Shell Script’ onto the main pane. This will add the action to the Shortcut’s flow.
- In the shortcut details (on the right pane), make sure Use as Quick Action is ticked and so are ‘Finder’ and ‘Service Menu’.
- In the newly added action called ‘Run Shell Script’ write “code “ and right-click to get the below pop-up, go ahead ‘Insert variable’ and then ‘Shortcut Input’.
- Click on the ‘Shortcut Input’ tag that appears. A pop must appear, choose ‘File Path’ and just click anywhere else. This will change the tag to ‘File Path’.
- Set ‘Pass Input:’ option to ‘as arguments’.
- Be sure to set a cool name for your new Shortcut! I named mine a boring “Open in VSCode”.
- Open a new ‘Finder’ Instance, right-click on a folder, go to ‘Quick Actions’ > ‘Customize...’
- Make sure your Shortcut’s Name is selected. Exit the dialogue and Test!

- 581
- 5
- 9
-
1Now we just need someone to turn this into some sort of install script and get it included inside VSCode for Mac as an install option – MattG Aug 26 '22 at 04:05
There is a Terminal command named code
, I would stick with it and you should get used to it as well if you are regularly using VS.
Follow the one-time setup with-in VS Code
Open your VS code and press ⌘ CMD + SHIFT + P
Type
shell
, and selectShell Command: Install 'code' command in PATH
from the list
Open Terminal and hit any of the commands below:
code <path-to-folder>
OR
cd <path-to-folder>
code .
OR
cd <path-to-folder> && code .

- 11,672
- 4
- 59
- 73
I find this to be the best solution out there: https://github.com/RoadToDream/SzContext

- 133
- 6
Here is an alternative derived from the accepted answer. Indeed the accepted solution by @jnovack just opens VS Code for me, but not the desired folder. If VS Code is already running it just switches the focus to a running instance of VS Code.
Solution
Provided that you have the code CLI command installed (if not, go to VS Code and do CMD+SHIT+P
>"Shell Command: install 'code' in PATH")
Then open a terminal and run which code
. You should get the code executable path looking somethin like /usr/local/bin/code
Then, as per @jnovack 's answer,
- Open Automator
- Create a new Document (
CMD+N
) - Create a new Quick Action
- Workflow receives current files and folders from Finder.
- Add a new Run Shell Script action to the workflow. (drag and drop the "Run Shell Script" object)
- Pass input as arguments
- Paste this code in the shell command field
/usr/local/bin/code -n "$*"
or replace with your path to the code executable if it differs from this one. - Save the action
Tbh. I would have expected to be able to use just code -n "$*"
, but for some reason, the PATH used by the automator's shell seems to be different from that used in the terminal. I'd welcome some input on that matter.

- 73
- 6
It's the simplest by creating a Shortcut
under Qucik Actions
:
Then edit:
Or downloading from my sharing link:
https://www.icloud.com/shortcuts/a34bf6a4e0ec463a9fb59343b5167dff

- 579
- 6
- 13
-
-
You have to explore "open file" action with two parameters where the first parameter would be "shortcut input" and its type should be "folder". make sure "show open in menu" is unchecked as it invalidates the "default App" parameter if you checked it. – Nishain de Silva Aug 02 '23 at 13:30