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)