Are you tired of the hassle of opening a folder in VS Code from the Finder in macOS? There’s no need to worry anymore because I’ve got a solution for you. With just a few simple steps, you can add an “Open in VS Code” icon to your Finder toolbar for easy access.

Let’s get started:

  1. First, open Automator and select “Application” as the type of document.

  2. Search for “Run Shell Script” in the list of actions and add it to your workflow.

  3. In the shell script, paste the following 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"

Alternatively, if you prefer using the bundle ID of the app, use the following script:

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"

These lines of code use AppleScript to get the path of the currently open folder in Finder. We then pass that path to the open command, which tells VS Code to open the folder.

  1. Save the application in the “Applications” folder. Then, right-click on the application and select “Get Info” to change its icon.

  2. Open the “Get Info” window for VS Code as well. Then, drag the VS Code icon from that window to the small icon in the top-left corner of the “Get Info” window for the application you created. This will assign the VS Code icon to your new “Open in VS Code” app.

  3. Finally, while holding down the ⌘ Command key, drag the application to the Finder toolbar.

That’s it! You now have an “Open in VS Code” icon in your macOS Finder toolbar. Whenever you want to open a folder in VS Code, simply click on the icon, and it will open the folder for you.

Now you can easily switch between Finder and VS Code without the need to manually locate and drag folders or use the terminal.

Tags: macOS, Finder, VS Code, toolbar, Automator