roadrunnertwice: DTWOF's Lois in drag. Dialogue: "Dude, just rub a little Castrol 30 weight into it. Works for me." (Castrol (Lois))

K, idk if y’all have ever messed around with the iOS “Shortcuts” app, but it turns out it is Legit.

So. On my Mac, I use a pair of oddball note-taking systems that I made out of baling wire, scrap lumber, and keyboard shortcuts over a decade ago and have been using daily ever since:

  • “Garbage Book” is just a clone of Apple Notes,* except that it uses my normal text editor instead of a separate app that I don’t like as much.
  • “FMP”** is, uh, baroque. There's a hotkey to get a text field that appends to a special text file. If I append a line that starts with something like ^didread, it’ll eventually get moved to a file like didread.txt (courtesy of a second hotkey that refreshes everything). And there’s yet another hotkey for quickly opening one of those note files by name.

    (I do realize what that all sounds like to a normal person, but trust me, it's a specialized ADHD workaround that solves some particular annoyances for me in a really sweet way.)

Since both sets of notes are just plain text files in a synced folder, I've always been able to access them on my phone. But it was way more awkward and slow, and I've always been on the lookout for ways to improve it.

Anyway, yesterday my dad was having brain surgery (he's doing fine, everything went great), and here's a thing about when someone close to you has major surgery: you sit around for a long-ass time, and you can't concentrate on any actual responsibilities for the whole duration (basically because the entire part of your mind that gives a flying fuck about responsibilities is wholly occupied with reacting whenever it's time to do something for said loved one). But a really frivolous and finicky project can be a great way to not obsess at 20,000 RPM over hypothetical stuff that you can't do anything about, so I decided to crack open that Shortcuts app that came out with iOS 12 and see if there was anything to it.

THERE IS. The card-based editing interface is weird as heck (it has some real strengths for programming on a touchscreen, but it also makes refactoring a pain in the ass, and was probably not intended for use on an iPhone SE), and the lack of some basic niceties like and/or expressions is pretty embarrassing (you can implement boolean logic yourself by adding more variables, but it looks like legit hell), but behind all that is a remarkably functional little scripting language with a coherent and consistent core and really unmatched discoverability.

It's probably even nicer for scripting apps that provide "real" Shortcuts actions, but even with just iA Writer's URL-based scripting and the built-in actions, I was able to completely*** re-implement both Garbage Book and FMP on my telephone over the course of two afternoons!

I now have little buttons on my "today" view for starting a new Garbage Book page, appending a line to my dump file, opening an FMP ^caret-tag file by name, and sorting ^caret-tag lines out of the dump file and into their real homes. (That was the one I didn't think would even be possible, but I totally did it!) And it all plays nicely with the edifice of Mac scripts that I've been using since '06.

Anyway, very satisfying results, a very impressive tool, also A+ distraction for that mandatory fret-in-the-hospital downtime.

_____

* Except this was ca. 2007 so it was more like a clone of Notational Velocity.

** Fast Memo Pencil? Fiendish Master Plan? Free Mashed Potatoes?

*** Wellll mostly completely. There's one thing I couldn't do on my phone from the original Garbage Book script: include part of the first line of text in the filename. That was always a nice feature, but c'est la vie; it's just a problem of different editing paradigms. In BBEdit I start by opening an empty editor window and typing for a while before hitting the Garbage Book hotkey to save, but in iA Writer I have to start by creating the file, so there's no first line of text to grab. I guess the editor itself could update the filename (Notes does this!), but it would have to know about my timestamped naming scheme to do that.

roadrunnertwice: DTWOF's Lois in drag. Dialogue: "Dude, just rub a little Castrol 30 weight into it. Works for me." (Castrol (Lois))
I got annoyed at something earlier today and decided to fix it, and FastScripts was once again the first tool I reached for, so I decided to finally shell out for it.

For the curious: I got sick of downloading PDFs I only intend to read once and then having them clog up the downloads folder, and I wanted a command to trash the file right from the PDF reader. (Preview isn't scriptable, of course, but you should be using Skim anyway.)

tell application "Skim"

set current_file to file of document of window 1

tell window 1 to close

tell application "Finder" to delete current_file

end tell

roadrunnertwice: Weedmaster P. Dialogue: "SON OF A DICK. BALL COCKS. NO. FUCKING." (Shitbox (Overcompensating))
So I was just thinking that I missed being able to automatically post the current music to LJ, back when I was using Xjournal. And that got me thinking about whether I could rig something up to just type the current track into the web form for me, right? Answer: Hell yes, I can! It is Applescript, and is predictably barbaric. Check it out:

Paste current iTunes track.scpt:

Some barbaric Applescript )

(I was originally going to just use the keystroke function to actually TYPE the text, instead of blowing away the clipboard, but this turns out to result in comedy for tracks with any non-ASCII characters.)

And then when I was about to post about how cool this was, I ran smack into how annoying it is to turn formatted RTF-ey text into a useful HTML fragment. So I wrote a script to do THAT for me, too. This one requires an external tool called "premailer," so you'll have to install that with gem.

This one SHOULD work with styled text copied from Word, TextEdit, or basically anywhere, but I haven't tested it very thoroughly yet.

Convert RTF clipboard to HTML fragment.scpt:

More barbaric Applescript )

As ever, just paste these into Applescript Editor, save them in ~/Library/scripts, and run them with FastScripts.