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):

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.

    Shortcut input set to receive Files and Folders from Quick Actions

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

    Action Library with shell script search results

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

    Shortcut details pane with Quick Action settings enabled

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

    Run Shell Script action with Insert Variable popup

  8. Click on the ‘Shortcut Input’ tag that appears. A pop-up must appear, choose ‘File Path’ and just click anywhere else. This will change the tag to ‘File Path’

    Shortcut Input tag showing File Path selection

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

    Pass Input set to as arguments

  10. Be sure to set a cool name for your new Shortcut! I named mine a boring “Open in VSCode”. 😅

    Shortcut named Open in VSCode

  11. Open a new ‘Finder’ Instance, right-click on a folder, go to ‘Quick Actions’ > ‘Customize…’ (ignore my already added Open in VSCode Shortcut)

    Finder right-click showing Quick Actions menu

  12. Make sure your Shortcut’s Name is selected. Exit the dialogue and Test!