Custom URL Handler to edit and preview Zettels from anywhere
I read a handful of posts (1, 2, 3) about custom URL handlers yesterday and I had a flash. Combining a custom URL with a unique ID means notes and links can become entirely independent from apps. Only the handler needs to know about the apps you're using. And I also realized that URLs can have query parameters! I wrote a blog post about the handler I designed. The whole script is over there.
In short the URL handler I created allows me to:
- Open zettel in my app of choice
zettel://202006061529, e.g. The Archive.
- Edit a zettel with in my editor of choice (FoldingText) with
- Preview it with in Marked with
- Pick an app to open the zettel with
- Create a new one with
zettel://create, again in The Archive.
If I change my mind and want to use TextMate instead of FoldingText, I can just change the script. This could also be expanded to create notes from a URL (supported by nvAlt/nvUltra, but not The Archive), e.g. in a bookmarklet.
The magic of finding the path to the file given only a zettel id is with the
mdfind -a ID command, which is the command line interface to Spotlight.
I also created a Keyboard Maestro macro to insert a link from anywhere. The second shell script in the screenshot below is:
#!/bin/sh echo "$KMVAR_filename" | sed -E -e 's/.[^.]*$//' -e 's!^([0-9]+)[[:space:]-]*(.*)!\1!'
Now I have to figure out how to make this work on iOS without having to make my own app to handle the
zettel:// link. I wonder I hard that would be…
It looks like you're new here. If you want to get involved, click one of these buttons!