Skip to content

Instantly share code, notes, and snippets.

@n8henrie
Created August 13, 2021 13:57
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 n8henrie/958856b77096949d4cfee9e4e99c48ed to your computer and use it in GitHub Desktop.
Save n8henrie/958856b77096949d4cfee9e4e99c48ed to your computer and use it in GitHub Desktop.
Quicksilver action to run a regex on input text
using terms from application "Quicksilver"
on get direct types
return {"NSStringPboardType"}
end get direct types
on get indirect types
return {"NSStringPboardType"}
end get indirect types
-- thirdPaneStuff is optional
on process text textToSearch with regex
try
-- Fix newlines https://stackoverflow.com/a/882136
set regexResult to do shell script "/opt/homebrew/bin/perl -pe 's/\\R/
/g' <<< " & quoted form of textToSearch & " | /opt/homebrew/bin/perl -pe " & quoted form of regex
tell application "Quicksilver" to set selection to regexResult
on error a number b
activate
display dialog a with title "error with your QS action script"
end try
end process text
on get argument count
return 2
end get argument count
end using terms from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment