Skip to content

Instantly share code, notes, and snippets.

@guilhermemmb
Created August 8, 2025 11:23
Show Gist options
  • Select an option

  • Save guilhermemmb/ea711f1bb1eed74f633af5b410b9354b to your computer and use it in GitHub Desktop.

Select an option

Save guilhermemmb/ea711f1bb1eed74f633af5b410b9354b to your computer and use it in GitHub Desktop.
appelscript to open a new tab in warp and run the command afterwards
#!/usr/bin/osascript
on run argv
-- Get the command to run from the first argument
if (count of argv) < 1 then
error "Usage: warp-new-tab.applescript \"command to run\""
end if
set commandToRun to item 1 of argv
-- Run in background with ignoring application responses
ignoring application responses
tell application "Warp"
activate
end tell
end ignoring
-- Give Warp more time to activate
delay 1.0
tell application "System Events"
tell process "Warp"
-- Wait for Warp to be frontmost with timeout
set maxWait to 20 -- 2 seconds total
set waitCount to 0
repeat until (frontmost is true) or (waitCount > maxWait)
delay 0.1
set waitCount to waitCount + 1
end repeat
-- If Warp is ready, proceed
if frontmost then
-- Create new tab (CMD+T)
keystroke "t" using command down
delay 1.2 -- More time for tab creation
-- Type the command
keystroke commandToRun
delay 0.3
-- Execute the command
keystroke return
else
error "Warp did not become frontmost in time"
end if
end tell
end tell
return "Successfully created new tab and ran command"
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment