diff --git a/extensions/RunCommand.popclipextz b/extensions/RunCommand.popclipextz index 9b5a7709..53f7b16e 100644 Binary files a/extensions/RunCommand.popclipextz and b/extensions/RunCommand.popclipextz differ diff --git a/source/RunCommand.popclipext/Config.json b/source/RunCommand.popclipext/Config.json index ca7ff0fe..d91acb67 100644 --- a/source/RunCommand.popclipext/Config.json +++ b/source/RunCommand.popclipext/Config.json @@ -12,19 +12,12 @@ ], "applescript file": "terminal.applescript" }, - { - "requirements": [ - "text", - "option-term=iTerm2" - ], - "applescript file": "iterm2.applescript" - }, { "requirements": [ "text", "option-term=iTerm2 v2.9+" ], - "applescript file": "iterm2-3.applescript" + "applescript file": "iterm2.applescript" }, { "requirements": [ @@ -41,11 +34,15 @@ "values": [ "Terminal", "iTerm2 v2.9+", + "Warp" + ], + "valueLabels": [ + "Terminal", "iTerm2", "Warp" ], "identifier": "term" } ], - "description": "Run the selected text as a terminal command. Supports both Terminal and iTerm2. (Now updated for iTerm2 v2.9.)" -} + "description": "Run the selected text as a terminal command. Supports Terminal, iTerm2 and Warp." +} \ No newline at end of file diff --git a/source/RunCommand.popclipext/README.md b/source/RunCommand.popclipext/README.md index 283c09fa..18b829fe 100644 --- a/source/RunCommand.popclipext/README.md +++ b/source/RunCommand.popclipext/README.md @@ -1,19 +1,17 @@ -RunCommand -============== +# RunCommand Run Terminal Command extension for PopClip. -One can choose either Terminal or iTerm2. +Runs the selected text as a command in the current Terminal window. + +One can choose either Terminal, iTerm2 or Warp Terminal. 2 Jun 2015: Separated the two sides into separate actions. Having both apps referenced in one script was causing problems. 19 Feb 2016: Added third config option to support iTerm2 v2.9 and above, which has breaking AppleScript changes. -28 Mar 2024: Added fourth config option to support Warp Terminal. - -Credits -------- -Original extension and icon created by [James Smith](https://twitter.com/smithjw/status/244757999665700864). +28 Mar 2024: Removed the legacy iTerm option and added Warp Terminal. -iTerm option added by [honnix](https://github.com/honnix). +## Credits +Original extension and icon created by [James Smith](https://twitter.com/smithjw/status/244757999665700864). iTerm option added by [honnix](https://github.com/honnix). Warp support added by Oliver using script from [parterburn](https://gist.github.com/parterburn/e832b9090ee35eb830529de8bd978b82). diff --git a/source/RunCommand.popclipext/iterm2-3.applescript b/source/RunCommand.popclipext/iterm2-3.applescript deleted file mode 100644 index f01e59b8..00000000 --- a/source/RunCommand.popclipext/iterm2-3.applescript +++ /dev/null @@ -1,9 +0,0 @@ --- new version of script for iTerm2 v2.9+ -tell application id "com.googlecode.iterm2" - activate - set _session to current session of current window - tell _session - set command to get the clipboard - write text "{popclip text}" - end tell -end tell \ No newline at end of file diff --git a/source/RunCommand.popclipext/iterm2.applescript b/source/RunCommand.popclipext/iterm2.applescript index d8224da7..f01e59b8 100644 --- a/source/RunCommand.popclipext/iterm2.applescript +++ b/source/RunCommand.popclipext/iterm2.applescript @@ -1,6 +1,7 @@ +-- new version of script for iTerm2 v2.9+ tell application id "com.googlecode.iterm2" activate - set _session to current session of current terminal + set _session to current session of current window tell _session set command to get the clipboard write text "{popclip text}" diff --git a/source/RunCommand.popclipext/warp.applescript b/source/RunCommand.popclipext/warp.applescript index 8b867a6d..42106490 100644 --- a/source/RunCommand.popclipext/warp.applescript +++ b/source/RunCommand.popclipext/warp.applescript @@ -1,9 +1,62 @@ -tell application "Warp" - activate - -- If there are no open windows, open one. - if (count of windows) is less than 1 then - do script "" - end if - set theTab to selected tab in first window - do script "{popclip text}" in theTab -end tell +-- 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 : false + +-- 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" + activate + tell application "System Events" + tell process "Warp" + set frontmost to true + end tell + end tell + end tell +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 + +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("{popclip text}") \ No newline at end of file