How to add an “Open in VS Code” icon in macOS Finder
Let’s say I’m in the Finder, I open a folder and I want to open it in VS Code.
What do I do? I typically move to the parent, grab that folder, and drop it into the VS Code icon in the Dock.
Or I go to the terminal and type code .
But today I invested some time into making this process much easier, with a button in the Finder toolbar:
![]()
Here’s how you can do that too.
Open Automator. Pick “Application”
![]()
Search for “Run Shell Script” in the list of actions, and paste these 2 lines:
finderPath=`osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)'`
open -n -a "Visual Studio Code" --args "$finderPath"
![]()
If you prefer you can use the bundle ID of the app:
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"
The first runs osascript (which is a script to run AppleScript) with the following AppleScript
tell application "Finder" to get the POSIX path of (target of front window as alias)
which basically gets the current opened folder absolute path.
Then we assign that to the shell variable finderPath and we use that with the open command to tell VS Code to open that folder.
Save this application in the Applications folder and then click Get info to change its icon.
![]()
You can open Get info on VS Code too, and drag the VS Code icon to the top-left small icon to assign that icon to our new little app.
![]()
Finally keep the ⌘ command key pressed and drag the app in the Finder toolbar.
![]()
That’s it!
download all my books for free
- javascript handbook
- typescript handbook
- css handbook
- node.js handbook
- astro handbook
- html handbook
- next.js pages router handbook
- alpine.js handbook
- htmx handbook
- react handbook
- sql handbook
- git cheat sheet
- laravel handbook
- express handbook
- swift handbook
- go handbook
- php handbook
- python handbook
- cli handbook
- c handbook
subscribe to my newsletter to get them
Terms: by subscribing to the newsletter you agree the following terms and conditions and privacy policy. The aim of the newsletter is to keep you up to date about new tutorials, new book releases or courses organized by Flavio. If you wish to unsubscribe from the newsletter, you can click the unsubscribe link that's present at the bottom of each email, anytime. I will not communicate/spread/publish or otherwise give away your address. Your email address is the only personal information collected, and it's only collected for the primary purpose of keeping you informed through the newsletter. It's stored in a secure server based in the EU. You can contact Flavio by emailing [email protected]. These terms and conditions are governed by the laws in force in Italy and you unconditionally submit to the jurisdiction of the courts of Italy.