This is how to run Cursor Composer from Terminal
Save this into a file, e.g.: cursor_prompt.scpt using Apple's Script Editor.
on run argv
if (count of argv) is 0 then
return
end if
set userPrompt to item 1 of argv
-- Check if Cursor is running
if application "Cursor" is not running then
tell application "Cursor" to launch
delay 2
end if
-- Check if Cursor is frontmost
tell application "System Events"
if not (exists process "Cursor") or not (frontmost of process "Cursor") then
tell application "Cursor" to activate
delay 1
end if
end tell
-- Check if there's an existing window before creating new one
tell application "System Events"
tell process "Cursor"
if not (exists window 1) then
keystroke "n" using command down
delay 1
end if
end tell
end tell
-- Wait for Cursor window to appear and be ready
tell application "System Events"
repeat until (exists window 1 of process "Cursor")
delay 0.5
end repeat
-- Additional delay to ensure UI is fully responsive
delay 1.5
end tell
tell application "System Events"
tell process "Cursor"
-- Simulate Tab
keystroke tab
delay 0.5
-- Simulate Command + I
keystroke "i" using command down
delay 0.5
-- Paste the prompt
set the clipboard to userPrompt
keystroke "v" using command down
end tell
end tell
end runMake sure it is executable:
chmod +x cursor_prompt.scptRun it:
osascript cursor_prompt.scpt "Write a Python function that calculates the fibonacci sequence"You can use and modify it as you need