Alfred 2 Workflow: Cheaters

Hit your hotkey and Cheaters will appear in a web-popup.

Cheaters is a customizable cheat sheet system for OS X written by Brett Terpstra.

cheat

Links

Notes

Requires Git to get the Cheaters source code. I tested with Git v1.7.12.4 and v1.8.2.1. I could use curl, but I’d like to get it updating from upstream repos.

The script has simple logic:

  • checks if git is installed, if not, exit.
  • checks if Cheaters is already installed:
    • if not, clone repo from GitHub into the workflow directory, then run workflow.
    • if true, then check if it’s a git repo:
      • if not, exit.
      • if true, check if there are any uncommitted/untracked/unstashed files:
        • if not, update the repo (not sure this is needed, updating from remote origin/upstream was my plan), then run the workflow.
        • if true, ask user if they want to overwrite/reset, then run the workflow.

One slight complication/hack is that there are two Automator workflows.

The first runs an AppleScript that starts the second Automator workflow, waits for a couple of seconds then kills the “Automator Launcher” process that started the second Automator workflow. If the launcher process is not killed, the Automator progress spinning gear appears in the Menu Bar and keeps spinning until you close the web-popup.

To-Do

  • Find more elegant solution to the Automator Launcher spinning gear icon hack. I tried this as both an Automator workflow and an application, both spawn the spinning gear. If everyone had Bartender, the spinning gear could be hidden by Bartender and there would be no need for the two workflows. Suggestions welcome!
  • Update Cheaters git repo from origin/upstream master.
  • Show progress indicator when cloning/updating.
  • DONE: Implement update logic. I should have put the git repo in ~/Library/Application Support/Alfred 2/Workflow Data/$bundle_id. As it is now, the Cheaters git repo is wiped out when you install a new version of the workflow.
  • DONE: Make Alleyoop compatible.

Update – 16th April 2013

Updated to v1.3 to fix various issues with spaces in paths. The download link above points to the new version, GitHub is updated and Alleyoop should pick up the update too.

Leave a Reply