Skip to content

Instantly share code, notes, and snippets.

@tonysneed
Last active February 6, 2025 07:50
Show Gist options
  • Save tonysneed/f9f09bfa28bcf98e8d8306f9b21f99e2 to your computer and use it in GitHub Desktop.
Save tonysneed/f9f09bfa28bcf98e8d8306f9b21f99e2 to your computer and use it in GitHub Desktop.
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
@adeguntoro
Copy link

wow...thanks man, still works with Mojave.

@posburn
Copy link

posburn commented Jun 28, 2023

This is great, thanks!

Copy link

ghost commented Nov 2, 2023

Brilliant! Thanks

@Tiisetso
Copy link

Still works in MacOS Sonoma Mar 2024. Thank you! The "Quick Action" tip from above still applies.

@xc1427
Copy link

xc1427 commented Feb 6, 2025

In 2025, for MacOS Sonoma 14.4.1, I adapt it to behave like "Open in Cursor", and it works.

Use the following steps,

  1. Open Automator
  2. File > New
  3. Select Quick Action
  4. Click Choose
  5. Select "Workflow receives current files or folders in Finder"
  6. From the left hand side pane in Automator, drag-drop Library > Utilities > Run Shell Script into the right hand pane
  7. Ensure Pass input is set to "as arguments"
  8. Then paste the below text:
for f in "$@"
do
    open -n -a "Cursor.app" --args "$f"
done

Then,

  1. Click File > Save
  2. Give name as "Open in Cursor"
  3. Go to Finder, select a folder or files, right click > choose Quick Actions > Open In Cursor

@xc1427
Copy link

xc1427 commented Feb 6, 2025

But If somebody can fork this OpenInCode project and makes it work for cursor, I will highly appreciate it.

I have tried and haven't figured it out, but its code is relatively simple.

@jaekookang
Copy link

Thanks to @xc1427 for sharing the method using the shell script.
I rather used simply Automator's built-in feature without using the shell script.
Let me share it here if it helps.

  1. Open Automator
  2. File > New
  3. Select Quick Action
  4. Search for "Open Finder Items" and drag it to the right panel
  5. Set "Workflow receives current" value to "Automatic (files or folders)" in "any application"
  6. Under Open Finder Items, change Open with: "Default Application" to Open with: "Cursor.app"
  7. Save with a custom name (e.g., Open with CursorAI)

sh2_250206
sh_250206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment