Skip to content

Instantly share code, notes, and snippets.

@pattiereaves
Last active May 7, 2018 08:15
Show Gist options
  • Save pattiereaves/20fccdf2274107a9443a8742aa1cd5ea to your computer and use it in GitHub Desktop.
Save pattiereaves/20fccdf2274107a9443a8742aa1cd5ea to your computer and use it in GitHub Desktop.
My favorite automator scripts

Attaching automator scripts to keyboard shortcuts

Once you create an automator script, you can run them by going to the application menu and choosing services (for example, Chrome > Services > j2m). Or you can one-up your game and attach the service to a keyboard shortcut.

To do that, go to System Preferences > Keyboard > Shorcuts.

Then, in the shortcuts, go to Servies and then scroll down to Text.

You should be see the service you have created in that list and can add a keyboard shortcut to it.

/**
Open automator
New Service
Service recieves selected text in any application
Check output replaces selected text
Enter the text below as "Run JavaScript"
**/
function run(input) {
var inputString = input[0];
var ticketMatches = /([a-z]+\ [0-9]+)\ (.*)/i.exec(inputString);
var ticketNumber = ticketMatches[1].toUpperCase().replace(/ /g, '-') + ':';
var description = ticketMatches[2].charAt(0).toUpperCase() + ticketMatches[2].slice(1) + '.';
return ticketNumber + ' ' + description;
}
# Before creating, run `npm i -g j2m` from the command line
# Open automator
# New Service
# Service recieves selected text in any application
# Check Output replaces selected text
# Enter the line below as "run shell script"
/usr/local/bin/node /usr/local/bin/j2m -i - -o - --toJ --stdin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment