Skip to content

Instantly share code, notes, and snippets.

@TitusRobyK
Last active August 25, 2024 22:23
Show Gist options
  • Save TitusRobyK/cdaa1cea63154ad1d72c1a4085b05822 to your computer and use it in GitHub Desktop.
Save TitusRobyK/cdaa1cea63154ad1d72c1a4085b05822 to your computer and use it in GitHub Desktop.
To enable the option to open a folder directly in Visual Studio Code from Finder with a right-click
1) Open the Automator app on your Mac.
2) Choose New Document and select Quick Action
3) In the top section of the Automator window, ensure the following settings:
Workflow receives current: files or folders
in: Finder
4) In the search bar, type "Run AppleScript" and drag the action to the workflow area.
5) Use the following AppleScript code:
on run {input, parameters}
repeat with i in input
set folderPath to POSIX path of i
do shell script "/usr/local/bin/code " & quoted form of folderPath
end repeat
end run
6) Save the workflow and test it by selecting a folder in Finder and using your Quick Action.
Explanation:
This AppleScript iterates over the selected items (input) and converts each item to a POSIX path (a format that shell scripts can understand).
The do shell script command then calls the code command with the folder path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment