Cheaters For Keyboard Maestro Macro And Updating Cheat Sheets from nvALT
When learning new shortcuts for an application or when in need of taking a quick glance at reference material for a project, I often find myself plowing through nvALT. It’s my database for everything. One of my common routines is navigating back and forth, adding information in one note whilst looking at another for referential purposes. Recently I switched from Terminal to iTerm 2, in addition I wanted to amp up my shortcut game with Sublime Text. What I needed was a quick way to browse my shortcut cheat sheets. After looking for good ways to build a tool I remembered Brett Terpstra’s Cheaters and decided that it is the perfect tool for the job.
Cheaters sheets can link to images or take converted Markdown files which makes the whole thing super easy to use. If you want to know more about populating Cheaters with your references, just head over to the official site.
The big ‘but’ for me was that after heavily using it after Brett’s initial released, I started neglecting Cheaters for quite a while. This was due to 2 facts:
- I was to lazy to convert my Markdown notes from nvALT (definitely the place where I write and collect references) and copy them to the Cheaters directory. Plus, I need to add new notes to the
file. - When calling up Cheaters it always bugged me that I couldn’t press the escape key to dismiss it directly. I have to click on the window first to make it active, only then I can close it via ESC.
Pretty minor complaints, but they were enough to make me not use Brett brilliant utility. I’m glad to say, I fixed both issues thanks to Keyboard Maestro and a bit of AppleScript voodoo.
Cheaters for Keyboard Maestro
Brett recently updated Cheaters and released Cheaters for Alfred and it now supports kind of a fuzzy search thanks to some mysterious JavaScript magic:1
[…] you can type “cheat keyword” to jump straight to a specific cheat sheet. For example, “cheat jq” would jump to jQuery, and “cheat git” would jump to the Git cheat sheet, assuming you have it active. Brett Terpstra
It’s very comfortable to use and Keyboard Maestro users obviously deserve a version, too. Why do Alfred users always get the good stuff, right? So, here’s my ripp off of Brett’s version:
What you need to make this work is the Cheaters KM app2 I attached below. I’m not sure if you need to open it once to get it recognized by Keyboard Maestro. Just do it one time, let it fail and you’re on the safe side. Also, don’t forget to update to the latest Cheaters version. Head over to Brett’s site now and download it.
After you filled in your username and the UNIX path where Cheaters is located (e.g. /Users/pat/Dropbox/cheaters/
) you can call it with a hot key and type in bin
to open Brett’s Keybindings cheat sheet – just like in Alfred.
For the curious ones: getting Cheaters to directly accept an ESC all you have to do is tell Applescript to activate it, which brings its window to the front. Even if you don’t want the Keyboard Maestro version and prefer opening Cheaters the traditional way, I’d suggest to build a short AppleScript wrapper and make it open Cheaters for you this way.
Creating and updating Cheat Sheets
Have I mentioned before that I live in nvALT. I guess so. That’s why adding to an existing reference file and updating the corresponding cheat sheet is crucial for making Cheaters work for me. Here’s the itinerary:
Update an existing Sheet
If you choose “no” and want to update an existing cheat sheet, the currently selected note in nvALT will get rendered as HTML file. A list opens up and you can choose which Cheaters file you want to replace.
For the conversion you need to have Fletcher Penny’s MultiMarkdown installed. Download it, install it and you’re good to go.
Create a new Cheat Sheet
If you decide to create a new cheat sheet you’ll get prompted for a name. Like before, your nvALT note gets converted to HTML. For your convenience a link will be placed in the clipboard and your text editor of choice will open up Cheaters index.html
file. All you have to do is paste the link at the position where you want it be and you’re set.
Additional Notes
In Keyboard Maestro you need to fill in the Configuration details in the AppleScript (the path to your nvALT notes, to Cheaters, the icon, your favorite editor, …).
If you don’t like the prompt and search pop-up there’s another macro included which presents you with a list of your cheat sheets. In case you prefer this one, you’ll have to adjust the AppleScript and trim down or expand the list of sheets to your liking. It’s a more effort and another file to manage.
The last addition is the raw AppleScript. Make a service out of it with ThisService or do whatever you want with it.
Disclaimer: Needless to say, but you need to have a note selected in nvALT for this to work. Hence, this won’t work:
Also, I don’t take any responsibility if you accidentally overwrite one of your cheat sheets. Just make sure you have the originals in nvALT and you will be fine.
UPDATE: Avoid creating notes with spaces in the filename. Cheaters files are html files which usually don’t handle that well. I haven’t added anything to prevent you from creating them or gracefully fail if you try to do so. I also organized the content of the zip file better and added a ReadMe file in the download packs to explain briefly how to setup Cheaters KM .
DOWNLOAD
DOWNLOAD COMPLETE PACK3
Credits
First and foremost, Mr. Terpstra himself ( – keep the legend alive and donate).
Cheaters for Keyboard Maestro uses the same icon Brett choose for Cheaters. It’s from Alessandro Rei.
Special thanks to Lauri Ranta who helped me with getting the currently selected note in nvALT.
-
My guess is that he wrote the code with his unicorn-leprechaun hybrid gloves in a full-moon night whilst singing Led Zepplin lyrics backwards. Dunno, but it has to be something like this. Well, that’s one of the secrets of the lab. ↩
-
The only thing this app does is handing over the URL which Keyboard Maestro generated and set to the clipboard. Then it passed it the Automator’s website pop-up action. ↩
-
(1) Cheaters KM for opening it and getting prompted which sheet to open and (2) the create new or modify old Keyboard Maestro + AppleScript macro. Also, (3) the original AppleScript and a list version of the create/modify macro. ↩