DEV Community

Harsh boricha
Harsh boricha

Posted on

⚙️ Shortcut: Open with Cursor/VSCode (Mac)

Every time I switch devices, I end up searching how to create this simple shortcut 😅 So I’m putting it here for good — and if it helps you too, awesome! 🙌💻✨

Automator Quick Action Screenshot

✅ Step 1 – Open Automator

Press Cmd + Space and type Automator, then hit Enter.

Choose Quick Action and click Choose.

✅ Step 2 – Configure Workflow Input

At the top of the window:

Workflow receives current: files or folders

in: Finder

Input: entire selection

You can choose any icon or color if you like, but it’s optional.

✅ Step 3 – Add Run Shell Script Action

In the search bar on the left, type Run Shell Script.

Drag Run Shell Script to the workflow area.

Configure it as follows:

Shell: /bin/zsh (or /bin/bash if you prefer)

Pass input: as arguments

✅ Step 4 – Add the Script for Cursor

Paste this inside the Run Shell Script block:

open -n -b "$(osascript -e 'id of app "Cursor"')" --args "$@"

✅ Notes:
osascript -e 'id of app "Cursor"' dynamically finds the bundle ID of Cursor, so you don't have to hardcode it.

"$@" ensures that all selected files/folders are passed correctly.

✅ Step 5 – Save the Quick Action

Press Cmd + S.

Name it Open in Cursor.

Click Save.

✅ Step 6 – Assign a Keyboard Shortcut

Open System Settings → Keyboard → Keyboard Shortcuts.

Go to Services → Files and Folders.

Find Open in Cursor.

Click it and assign the shortcut F12 (or any key you prefer).

✅ Step 7 – Test It

Select a file or folder in Finder.

Right-click → Quick Actions → Open in Cursor, or press F12.

✅ For VSCode, Modify the Script Like This:

If you want a similar shortcut to open files in VSCode, just replace the script with:
open -n -b "com.microsoft.VSCode" --args "$@"
This directly uses VSCode’s bundle ID without needing osascript.

✅ Final Notes

You can use osascript -e 'id of app "App Name"' for any app if you don't want to hardcode the bundle ID.

The -n flag ensures it opens a new instance.

The --args "$@" part forwards the selected files or folders to the app.

Top comments (0)