Skip to main content

'Create a new Drupal module' keyboard shortcut in OSX

Using OSX's Automator app it's easy to make a custom keyboard shortcut that will 'Create a custom module' in the folder you are currently in. Here's how:

First you need to create a custom module from scratch for the last time ever! We will use this as the template every time we use our shortcut so save it somewhere it won't get deleted.

In this example the custom module we will use as a template is called, rather generically, 'custom_module'. You will need:

  • A folder called custom_module
  • Inside that folder you will need a custom_module.info file and a custom_module.module file.

You can get information on how to head these file up on the Drupal site, or you can download a zipped version of my example files.

Open Automator...

We are going to create a Service so choose the option 'Service'.

Create a service

Up the top of our Service choose 'no input' and 'Finder'.

From the actions column to the left, find 'Run AppleScript' and drag it over to the service.

Paste the following code in to the AppleScript.

on run {input, parameters}
  tell application "Finder"
    set currentPath to insertion location as text
    set x to POSIX path of currentPath
  end tell
  return x
end run

PRESS THE HAMMER!

Now find 'Set Value of a Variable' and drag it to the service underneath the AppleScript The create a new variable and call it CurrentFolder .

Now find 'Get Specified Finder Items' and drag it over the the service. Add the custom_module folder created earlier and under the options tick the box for 'Ignore this action's input'.

Find 'Copy Finder Items' and drag it over the the service. Where it says 'To:' drag the custom variable we created 'CurrentFolder'.

So that's our service - it should look a bit like this:

Now save the service as something meaningful like 'Create a custom module'.

Now the service is created we just need to create the keyboard shortcut. Under OSX's System Preferences > Keyboard > Keyboard Shortcuts select 'Services' and scroll down and find the service. Click next to the service to create the shortcut (I have used Command+Shift+M).

That's it! Now wherever you are in finder you can use this shortcut to create a custom module. PRODUCTIVITY!