I find it hard to believe, but all these years using a Mac running OSX (now MacOS, I suppose), I’ve never used Automator. Not until today, that is. I use Visual Studio Code (VSCode) all the time, and always have either opened a terminal (using iTerm2) and opened my projects via code ., or opened VSCode and then used the File|Open Folder… dialog box. Neither is very satisfying when I’ve got a Finder window open – which tbh isn’t that often; I find the Finder not terribly satisfying to use but that’s beside the point. Anyway… Here’s how to get it set up:
-
Launch Automator (Cmd-Space, type “Automator”)
Choose Quick Action
Choose “files or folders” in “Finder.app”
Add “Run Shell Script” by dragging it into the workflow area
Set Pass Input to “as arguments”
paste in this script
for f in "$@"; do
open -a 'Visual Studio Code' "$f"
done
select for full-size Save the workflow as “Open in VS Code”
Now you can go to any folder via the Finder, right-click on the folder, then choose “Open in VS Code” from the Quick Actions menu item.