Skip to content

Instantly share code, notes, and snippets.

@parterburn
Created September 27, 2022 16:51
Show Gist options
  • Save parterburn/e832b9090ee35eb830529de8bd978b82 to your computer and use it in GitHub Desktop.
Save parterburn/e832b9090ee35eb830529de8bd978b82 to your computer and use it in GitHub Desktop.
An easy way to use the Warp terminal (https://www.warp.dev/) with Alfred.
-- For the latest version:
-- https://gist.github.com/parterburn/e832b9090ee35eb830529de8bd978b82
-- Set this property to true to always open in a new window
property open_in_new_window : false
-- Set this property to false to reuse the current tab
property open_in_new_tab : true
-- Handlers
on new_window()
tell application "System Events"
tell process "Warp"
keystroke "n" using command down
end tell
end tell
end new_window
on new_tab()
tell application "System Events"
tell process "Warp"
keystroke "t" using command down
end tell
end tell
end new_tab
on call_forward()
tell application "Warp" to activate
end call_forward
on send_text(custom_text)
tell application "System Events"
tell process "Warp"
delay 0.5
keystroke custom_text
delay 0.5
key code 36
end tell
end tell
end send_text
-- Main
on alfred_script(query)
call_forward()
if open_in_new_window then
new_window()
else if open_in_new_tab then
new_tab()
else
-- Reuse the current tab
end if
call_forward()
send_text(query)
end alfred_script
@pilotmoon
Copy link

pilotmoon commented May 19, 2024

Thanks for this. I'm using it in the Terminal PopClip extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment