Automator is handy. It's a visual replacement for stringing together commands with pipes. Suppose you have an exposed REST endpoint which provides JSON data and you want to get some of this information into your clipboard. You can create an automator workflow which does this. All you have to do is execute the workflow. You can execute the workflow in two ways (that I've found useful):

  1. Add the icon to your dock and double click on it. Easy
  2. Execute the app with spotlight, just search and press enter.

Sweet. So how?

First, find your endpoint and test it out with cURL. You can find this url using Firefox or Chrome's inspect element/network tab. Look at the requests, pick it out, and right-click to copy the url/curl command.

Next install jq. This beautiful command is like awk for json. I installed it with Homebrew.

$ sudo brew install jq

Get it's location with which:

# Get the location of the binary for Automator
$ which jq

Create your automator workflow:

  1. Utilities -> Run Shell Script.

bash curl -s 2>/dev/null

  • The -s triggers silent mode, which may not be needed, but we do it anyway.
  • The 2>/dev/null redirects stderr to the black-hole. It's just a pseudo file descriptor. Automator will detect the output on stderr and stop the workflow, so we get rid of that output.

  • Utilities -> Run Shell Script.

We do it again, this time use jq to parse your data.

bash /usr/local/bin/jq -r .[0].text

  • We use the output of which from above because Automator doesn't have the same path as us. This way Automator can find the command.
  • We use -r to ask for raw output. This gets rid of quotes around the desired string.
  • The last part is a selector, and should be specific to you.

  • Utilities -> Copy to Clipboard

Just add this to the end, no setting.

Now click File -> Export and save your app file with an appropriate name. You're done!