Skip to content

Instantly share code, notes, and snippets.

@hohonuuli
Created February 19, 2024 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hohonuuli/70f741184c131ebed4f0c44eb03e0a3c to your computer and use it in GitHub Desktop.
Save hohonuuli/70f741184c131ebed4f0c44eb03e0a3c to your computer and use it in GitHub Desktop.
AppleScript to open a Warp tab at the current location in the finder
(*
WarpHere by Brian Schlining
2024-02-18
*)
-- when the toolbar script icon is clicked
--
on run
tell application "Finder"
try
set this_folder to (the target of the front window) as alias
on error
set this_folder to startup disk
end try
my process_item(this_folder)
end tell
end run
-- this subroutine processes does the actual work
-- this version can handle this weirdo case: a folder named "te'st"ö te%s`t"
on process_item(this_item)
set thePath to quoted form of POSIX path of this_item
set theCmd to "cd " & thePath & ";clear;"
tell application "Warp"
activate
-- just open Warp and cd to thePath
tell application "System Events" to tell process "Warp"
click menu item "New Tab" of menu "File" of menu bar 1
-- click menu item "New Window" of menu "File" of menu bar 1
set frontmost to true
end tell
delay 0.5
tell application "System Events"
tell application process "Warp"
keystroke theCmd
keystroke return
end tell
end tell
end tell
end process_item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment