Using the Mac ‘automator’ tool for fun and profit

Matt Oxley
4 min readApr 13, 2018

--

Since context effects are a thing, for some time I’ve been desirous of a kind of ‘workspace’ app for my Mac, a tool that will enable me to compartmentalise my machine into different combinations of apps suited for different tasks. This way I can focus on stuff that I have committed to focussing on, and increase the overhead involved in opening a completely unrelated app.

Apptorium’s Workspaces fits the bill reasonably well. Here you can define new workspaces, each with a list of associated applications, which you can either open one-by-one, or all at once:

Apptorium’s Workspaces is good for clustering related apps and launching with one click

This is handy, but what if I want to do something more involved? As a developer, if I want to switch over to a new project I will often do something like this:

  1. Open my project root in Sublime Text
  2. Open my project root in SourceTree
  3. Open iTerm, and `cd` into my project root, run `yarn start` or something like that, and open a new pane in the same directory ready for further commands
  4. Point my browser to JIRA
  5. Close whatever other crap I have open
  6. Open Spotify and play some incredibly productivity-facilitating beats

Enter Automator. It ships with OSX, and I can’t believe it has taken me 5 years as a Mac user to discover it. Among other things, you can you create workflows like the above and bundle them into a single application that you can launch at will.

Let’s build a workflow that matches the above:

  1. Open Automator.

2. Create a new document (CMD-N). Click to create a ‘application’ (but note that this is just the tip of the iceberg of what Automator has to offer).

3. Notice all the different actions that are available to you in the panel on the left hand side. Workflows are built by dragging actions into the main panel, and arranging them into a sequence. Since I want to set my Mac (and my brain) to a ‘clean state’ when I switch work into a new project, the first action I am going to drag is ‘Quit All Applications’. You can find this in the `Utilities` submenu.

4. Next, I want to open my project’s root directory in both Sublime Text and SourceTree. To do this, we are going to set up a sequence of actions that are going to look familiar to anyone who has used Unix pipes before. Look for ‘Get Specified Finder Items’ under the ‘Files & Folders’ section, drag it into the main window, and add your project root directory there.

5. Insert the ‘Open Finder Items’ action next, and specify whatever IDE you want your project root to be opened with. What is happening here is that the output from step 4 (folder path) is being passed as an input to this action. You can repeat this step with however many applications you want. For instance, I tend to add SourceTree too (I suck at git CLI).

6. In a similar manner to steps 4 and 5, I use ‘Get Specified URLs’ and ‘Display Webpages’ to define a list of sites I want to open on startup (e.g. JIRA, Bitbucket) and open them in the browser, respectively.

7. This last step is, in my view, the coolest. AppleScript is a language that provides you with the ability to interact closely with your applications, and you can insert such scripts wherever you like into your workflows. In this case I am going to insert a script that I found in a gist written by user alisonailea that automates the launch of a Spotify playlist depending on whatever time of day it happens to be (I personally respond better to different music at different points in the day, so for me, this isn’t just a gimmick).

Use the ‘Run AppleScript’ action to define and run arbitrary scripts

8. When you are done, click File -> Export to save as a Mac Application that can be launched as any other.

Finally, I often add my shiny new Application as its own workspace into the aforementioned Workspaces app, where it can be easily launched from the menubar. I’m sure this doesn’t do full justice to Workspaces, but its how I do things anyway.

It’s pretty clear that we’ve only scratched the surface of what Automator has to offer — I’m still learning about new actions and new ways to use it. If you have any use cases that are particularly beneficial to you, please do share below!

References:

Rothman, Miriam. “Designing work environments to influence productivity.” Journal of Business and Psychology 1.4 (1987): 390–395.

--

--

Matt Oxley

Software developer. Former research psychologist. Former blackjack dealer.