Shortcuts is nearly good

09/03/2024

Screenshot 2024 03 11 at 11 23 06

Shortcuts is such a good way to dip your toe in the water if you're potentially interested in programming in any way but have zero experience. But I'm still not really sure who it's actually intended for. You can do all sorts of cool things, but you have to do them in such an obtuse way sometimes that I can't imagine anyone derives any satisfaction from it at all.

It is super useful for some small tasks; especially things I might want to trigger from Siri. For example, I have a Where am I? shortcut that I use whilst driving if I drive past something cool and want to remember it later. This shortcut extracts my current location and adds a new todo in Things. I also have quick shortcuts for switching my Airpods between noise cancelling and transparency modes because the UI for that is buried in Control Center and it annoys me.

Probably my most-used ones are my Clean URL (if you install this, it'll likely nag you every time you use it on a new domain. I don't know why but it's really annoying and I wish you could make it stop) shortcuts. I absolutely hate that every single app has now started tagging share tracking onto URLs - if you share a video from YouTube or Instagram, they all have these little si= or fbclid= query parameters that they use to determine your real-life social circle, and I absolutely hate them. Personally I'm surprised the EU hasn't made them illegal as they're fundamentally far more insidious than cookies, but I digress. If you share a URL with someone and it has something that looks like a unique parameter that has nothing to do with the actual content, delete it before sharing it please. For example: https://youtu.be/XPvb6-klI_k?si=D7xSG0xevh47m2NZ this part si=D7xSG0xevh47m2NZ is a share ID, and if you click a URL like this and you're logged in, YouTube now knows that the person sharing a link, and the person who clicked it have network overlap, even if they're not connected on the platform. Gross. All these shortcuts do is rip off the query string from a URL - there's not a library of known share parameters - most URLs don't need the query string anyway and you can safely remove it (unless you're linking to a search or a product index on a shop or something).

Cycle Bluetooth is also useful, as MacOS still does not have the ability to do this. I will turn bluetooth off, but then my trackpad disconnects and I have no way to turn it back on. Cycle Bluetooth turns off Bluetooth, waits 2 seconds, then turns it back on.

But the shortcut I want to look at in detail today is my new Bookmark one. It's by far the longest I've ever made, and it took me far too long because of silly idiosyncrasies in Shortcuts' object model and comparison

Screenshot 2024 03 09 at 09 44 40

I recently decided that I'm not going to renew my Pinboard subscription. I have apparently had it for ten years, and I just don't really use it. It's become a bin for URLs that I will never revisit, and I shouldn't pay for things like that just because I've always paid it! Conveniently, iA Writer just added support for Shortcuts, so I've moved all my bookmarks and read-later to text files in my iA library. This automatically syncs across all the devices I use to browse URLs - it just fits for me. Truth be told, I don't use read-later that much now. If I'm not going to look at something now I tend to just leave the tab open. I have a couple of categories for things like code, music, things I might want to buy, but otherwise if I don't have something in front of me, it might as well not exist.

The premise of this shortcut is pretty simple - it takes input either from a Safari URL (on iOS) or a URL string (from Launchbar) and then tries to extract a title. It then prepends some Markdown to an existing file in iA for me to never look at again.

The reason that this became a pretty frustrating endeavour is in that comparison at the start. URLs received from Safari via share sheet have some extra metadata - namely the title. So that saves me a job. Except when I send via Launchbar, all we get is the URL, and when you try to extract the magic Name attribute from that, you just get the URL again. But comparing those two things always seems to be falsy, and Shortcuts doesn't have the debugging to allow me to figure out why. If I concatenate them both to a string, they're identical, but when I compare them they're not. So I went for the far-less-robuts "does it start with http - then it's probably a URL" approach that I dislike but it does, at least, work.

And that's it - now I can Cmd-L, double-Cmd, tab, type "book" and save URLs from my desktop (I swear this is easier than it seems), as well as from share sheet on my iOS devices. It was a real faff but I do think this is a super useful tool for Mac users to get to grips with, even if they have absolutely zero programming background. You might even find it easier than me, lacking that "it should work like this!" that comes with experience.

Screenshot 2024 03 09 at 10 06 42
Screenshot 2024 03 09 at 10 09 20
Listening:
Let's implement dynamic DNS using Crystal and Cloudflare Gadgets