Skip to content

Instantly share code, notes, and snippets.

@mergesort
Last active December 4, 2024 20:37
Show Gist options
  • Save mergesort/6ef6480bdbdfd5082c73be8f3f25b6e2 to your computer and use it in GitHub Desktop.
Save mergesort/6ef6480bdbdfd5082c73be8f3f25b6e2 to your computer and use it in GitHub Desktop.
Cursor -> Xcode -> Cursor AppleScript
tell application "System Events"
if (name of processes) contains "Xcode" then
-- Check if Xcode is already the active/focused application
if (name of first application process whose frontmost is true) is not "Xcode" then
tell application "Xcode 16.2 (Beta)"
activate
delay 0.25 -- Wait for Xcode to become active
end tell
end if
-- Simulate Command+R to run
tell application "System Events"
keystroke "r" using {command down}
end tell
-- Add a small delay to ensure the command is executed before switching apps
delay 0.25
-- Activate the Cursor app
if (name of processes) contains "Cursor" then
tell application "Cursor"
activate
end tell
else
-- Launch Cursor if it's not running
do shell script "open -a 'Cursor'"
end if
end if
end tell
{
"version": "2.0.0",
"tasks": [
{
"label": "Run in Xcode",
"type": "shell",
"command": "osascript",
"args": [
"'/Users/USER/path/to/your/script.scpt'"
],
"presentation": {
"reveal": "always"
},
"problemMatcher": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment