Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a folder in vscode through Finder in macOS?

On my windows pc, I would just double click a folder and click "Open in VS Code" to a open a folder, which saved time for me when looking through lots of code online. With Mac, however, I do not have this option. I have to directly open vscode and click "Open" to open a new folder. How do I directly open a file in vscode through finder in macOS?

like image 275
ansgup Avatar asked Sep 24 '20 06:09

ansgup


People also ask

How do I open a folder in VS Code Mac terminal?

If you already have a Terminal session running, quit or restart it. When you are in the directory of the files you want to open in VS Code, type code . (that is the word “code” followed by a space, then a period) and the folder will automatically open in VS code.

How do you open a folder in VS Code?

The File > Add Folder to Workspace command brings up an Open Folder dialog to select the new folder. Once a root folder is added, the Explorer will show the new folder as a root in the File Explorer. You can right-click on any of the root folders and use the context menu to add or remove folders.


1 Answers

If you want to do it in Finder, you can write an Automator script to do it (it's easier than it sounds, AND shows you the power of the OS).

  1. Launch Automator

  2. Create New Document

  3. Create a new Quick Action Select "Quick Action"

  4. Add the Action...

    • Workflow receives current files or folders from Finder.
    • Add a new Run Shell Script action to the workflow. (drag the "Run Shell Script" object, highlighted in the screenshot, to the empty window on the right)
  5. Configure the Workflow

    • Set the Pass Input to be as arguments
    • Paste the following in the input box:
    open -n -b "com.microsoft.VSCode" --args "$*"  

    Screenshot of Workflow

  6. Save the action using a name like Open In Visual Studio Code.

You may now right-click on the folder and find your newly created task under Quick Actions.

enter image description here

like image 182
jnovack Avatar answered Oct 06 '22 05:10

jnovack