yeah… i got that far… i am just trying to figure out how to say… “send this input to this script”… unless we can’t do that, and can only send to AppleScript?
In item 4 on the Envato Tuts link, you’ll see you can add both AppleScript and Shell Script. Use the AppleScript in that example to get the selected text. Use additional lines of AppleScript to save it to a file. Then run your shell script to read the content of the file and process it. Bundle it all up in a service, Keyboard Maestro, purely an AppleScript script (it could execute a shell script),…
Okay, for completion’s sake, I’ll post the results of my experiment.
I figured I would just write the script in ruby, since there are libraries to do everything, and the end product would be only a few lines or so. It turns out that this is a bit more hellish than I anticipated.
It turns out that this, while a giant pain, is quite doable, but unfortunately, not really shareable.
The automator gives you the choice to run using system ruby, or via a few different shells.
My day job is as a ruby developer, so my ruby environment is super customized. I had to do serious brain surgery to get the automator to run the script.
There were too many extra things that I would not want to ask a user to do to get my solution to work.
So, while everything mostly works, it’s still not something I would feel comfortable having someone add to their machine.
I am thinking of rewriting it in either swift or c++, so that I can provide a command line application that doesn’t have all the requirements that ruby has.