macOS: Open Files and Folders in VS Code from Finder
You probably already know that you can open the current directory in Visual Studio Code from Terminal with: code . That works well when you're already in Terminal. But if you're browsing a project in Finder , opening Terminal, navigating to the same directory, and typing code . can feel like unnecessary work. Instead, you can add Open in VS Code directly to Finder. In this guide, I'll show you…
Navigating a project in Finder can sometimes feel cumbersome when you need to open files in Visual Studio Code. Instead of launching Terminal, finding the directory, and typing `code .`, you can add a simple Finder action to open files directly in VS Code. This guide explains two ways to set it up: manually using the Automator app or automatically with a shell script.
To create the Quick Action manually, begin by opening the Automator app from the Applications folder or Terminal with `open -a Automator`. Create a new Quick Action by selecting “New Document → Quick Action.” Configure the workflow to receive current files or folders in Finder. Then, add a Shell Script action and replace the default script with `/usr/bin/open -b com.microsoft.VSCode $@`.
Save the workflow and test it by selecting a file or folder in Finder, right-clicking, and choosing Quick Actions → Open in VS Code. VS Code will open the selected item.
For an automated setup, download the installer script from the GitHub repository. Clone the repository with `git clone https://github.com/moyarich/Open-Files-and-Folders-in-VS-Code-from-Finder.git` and navigate to the project directory. Make the installer executable with `chmod +x ./install-open-in-vscode-plugin.sh` and run it with `zsh ./install-open-in-vscode-plugin.sh install`.
The script sets up the Quick Action, adds the VS Code command, and configures Finder as the input location. Test the installation by right-clicking a file or folder in Finder and selecting Quick Actions → Open in VS Code.
To add a keyboard shortcut for frequent use, go to System Settings → Keyboard → Keyboard Shortcuts → Services, find Open in VS Code, and assign a custom shortcut. Uninstall the Quick Action by running `zsh ./install-open-in-vscode-plugin.sh uninstall` if needed. The core command powering both methods is `/usr/bin/open -b com.microsoft.VSCode $@`, which opens the selected Finder items in Visual Studio Code.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.