# How to add an “Open in VS Code” icon in macOS Finder

> Learn how to add an Open in VS Code button to the macOS Finder toolbar using an Automator app that runs a shell script with osascript and the open command.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2023-01-28 | Topics: [Mac](https://flaviocopes.com/tags/mac/) | Canonical: https://flaviocopes.com/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:

![VS Code icon button in macOS Finder toolbar next to other toolbar buttons](https://flaviocopes.com/images/how-to-add-an-open-in-vs-code-icon-in-macos-finder/1.webp)

Here’s how you can do that too.

Open Automator. Pick “Application”

![Automator application window showing template selection with Application option highlighted](https://flaviocopes.com/images/how-to-add-an-open-in-vs-code-icon-in-macos-finder/2.webp)

Search for “Run Shell Script” in the list of actions, and paste these 2 lines:

```shell
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"
```

![Automator workflow with Run Shell Script action containing the osascript and open commands](https://flaviocopes.com/images/how-to-add-an-open-in-vs-code-icon-in-macos-finder/3.webp)

If you prefer you can use the bundle ID of the app:

```shell
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 

```shell
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. 

![Get Info dialog window for the Automator application showing icon customization options](https://flaviocopes.com/images/how-to-add-an-open-in-vs-code-icon-in-macos-finder/4.webp)

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.

![Dragging VS Code icon from Get Info dialog to replace the default Automator application icon](https://flaviocopes.com/images/how-to-add-an-open-in-vs-code-icon-in-macos-finder/5.webp)

Finally keep the ⌘ `command` key pressed and drag the app in the Finder toolbar. 

![Dragging the VS Code application to the Finder toolbar while holding the command key](https://flaviocopes.com/images/how-to-add-an-open-in-vs-code-icon-in-macos-finder/6.webp)

That’s it!
