Adding a right-click option to open files or folders with Visual Studio Code (VSCode) on a Mac involves creating a service using Automator, a macOS tool for automating tasks. Here's a step-by-step guide to achieve this:
-
Open Automator:
- Go to your Applications folder and open Automator.
-
Create a New Service:
- In Automator, select
File > New
. - Choose
Service
orQuick Action
(depending on your macOS version).
- In Automator, select
-
Configure the Service:
- At the top of the right pane, you'll find two drop-down menus.
- Set the first one to
files or folders
and the second toFinder
.
-
Add a Run Shell Script Action:
- In the search bar on the left, type
Run Shell Script
. - Drag the
Run Shell Script
action to the right pane. - In the
Run Shell Script
action, setPass input
toas arguments
.
- In the search bar on the left, type
-
Enter the Shell Script:
- Type the following script in the text box:
for f in "$@" do open -a "Visual Studio Code" "$f" done
- This script will open each selected file or folder in VSCode.
- Type the following script in the text box:
-
Save the Service:
- Go to
File > Save
. - Name it something like
Open with VSCode
.
- Go to
-
Test the Service:
- Right-click on any file or folder in Finder.
- You should see
Open with VSCode
in the context menu (you might have to look underServices
).
-
Assign a Keyboard Shortcut (Optional):
- Go to
System Preferences > Keyboard > Shortcuts
. - Select
Services
from the left pane. - Find your
Open with VSCode
service. - Add a keyboard shortcut if you like.
- Go to
That's it! You now have a custom right-click option to open files or folders with VSCode on your Mac. This should streamline your workflow, especially as a Python developer and tech enthusiast.