MacOS – OSX: how to add a right click option to a folder which opens the folder with an app like VS Code

macos

Is it possible to add a service to a folder so as to open it with a specific application?

As shown in the screenshot below, an application named Evernote has done this. I want to do it manually for VS Code and Brackets.

enter image description here

Let's take VS Code for an example. It is a text editor that opens a folder in it and allows a user to edit the text files in the folder and its subfolders. There are so many other applications in the market like Sublime, Adobe Brackets and so on.

The folder hierarchy looks like this:

enter image description here

In order to open the folder in the app, I have to open the app, then go to the open folder option, then find the folder, then select and click on the open button.

Instead of this, I want an option in the right click menu of the folder to open the folder directly with the text editor. Just like you can open a folder in Terminal by adding a service.

Best Answer

You can do this with an Automator Service.

Create the Service:

  1. Open Automator and select Service or File > New > Service If Automator is already open.

  2. Set Service receives selected to files or folders and in to Finder.

  3. Add a Run Shell Script Action, setting Shell: to /bin/bash and Pass input: to as arguments and add the following code:


for f in "$@"; do
    open -a 'Visual Studio Code' "$f"
done

  1. Save the Service as Open in Visual Studio Code.

enter image description here

  1. Close Automator.

You can now select Files and or Folders in Finder and then control-click (right-click) on them and select Open in Visual Studio Code from the Services Context Menu.

Note: I tested this with Visual Studio Code but not with Brackets as I don't have it installed. However you should be able to create one for it too in the same manner while substituting the application's name in the open command.