I have been struggling with dragging and dropping folders onto open VS Code instances to open folders for some time. I liked how you could right-click and open a folder on VS Code directly from the Right-Click Popup Menu on my Windows Machine (fig below):

Untitled

So I found a way using MacOS’ Shortcuts! (Without using Automator)

Here are the steps:

  1. Open the ‘Shortcuts’ app on your Mac
  2. On the Left Pane, navigate to ‘Quick Actions’
  3. On the top bar, press the ➕ button to add New Shortcut.
  4. Click on ‘Any’ and change to ‘Files and Folders’ by selecting only those from the dropdown that appears on clicking the ‘Any’ field.

Untitled

  1. 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.

Untitled

  1. In the shortcut details (on the right pane), make sure Use as Quick Action is ticked and so are ‘Finder’ and ‘Service Menu’.

Untitled

  1. 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’

Untitled

  1. 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’

Untitled

  1. Set ‘Pass Input:’ option to ‘as arguments’