569: Contextual Computing

Both Devonthink and Drafts prefer using UUID rather than paths (as Finder does for file:// links), so they don’t break when moving.

Others, like Obsidian and Finder, prefer using absolute/relative paths to a file. Those will break if the file is moved or renamed because the previous path in the link will no longer point to the corresponding file.

A workaround is to use a third party app (such as Hook or Devonthink) that has the ability to create and monitor a database of files and use its own link to refer to the file on the system. That will require for the indexing part of the app to be running when file is moved or renamed.

3 Likes

Do you compartmentalize in such a way due to personal preference (one app for one area of work) or is there a specific practical reason which makes Craft/DT more suitable for one of the two use cases and vice versa?

1 Like

Two thoughts:

  1. Conflict palette is great.
  2. The real problem for me with Contextual Computing is deciding what the contexts are and what goes in them. For me, these are leaky containers.
1 Like

Personal preference, but the Markdown support is more handy for work stuff, too.

1 Like

Regarding Notes support for Hook: This was bugging me, so I looked into it further. Short version: Hook supports Notes in Mavericks and Big Sur, and has partial support for Notes in Catalina. More information:

Interestingly, Hook uses the note creation date and time as a unique identifier for each note, which is very clever indeed!

Awesome tip, Chris! However, you lost me on URL encoding the pathname before putting file:// in front of it. How do you do that?

So, start with the file path:

/Users/chris/Documents/Test File.txt

The problem here is that URLs can’t have spaces in them. When I paste it into Things, it assumes that the space is the end of the URL and tries to link to a file named ‘Test’ instead of ‘Test File.txt’:

Screen Shot 2021-01-07 at 11.24.20 AM

We could just never use spaces in our file paths, but the Mac has supported spaces in file and folder names since time immemorial. Instead, we can get around this by URL encoding the path, replacing the space with %20. You could do this manually, but that would be a pain and we’d also have to replace any other characters that aren’t valid in a URL. Instead, we can use URL encoding software to make all the necessary substitutions for us. If you want to play around with it, there are websites that will URL encode text for you. If this is something you want to make part of your workflow you probably want to script it (this can be done using the Filter action in Keyboard Maestro and setting it to “Percent Encode for URL”).

This gives us:
%2FUsers%2Fchris%2FDocuments%2FTest%20File%2Etxt

In order to make Things or other programs that automatically convert URLs to links recognize this as a URL we need to put file:// in front of the URL-encoded path (just like URLs for websites have “http://” at the front).

file://%2FUsers%2Fchris%2FDocuments%2FTest%20File%2Etxt

Now when I paste this into Things it recognizes the whole string as a URL and doesn’t stop at the space:

Note that when I hover over the link, Things automatically decodes the URL turning %2F into a slash and %20 into a space:

If I click the link it will open my Documents folder in a Finder window with Test File.txt selected. ⌘-O will open it in whatever the default app is for that file type.

3 Likes

Great episode guys!

@MacSparky David, could you explain how your “minimize all windows” Keyboard Maestro macro works or what actions it uses? I can’t find a way to minimize all in the “manipulate a window” action. I was hoping it was a downloadable macro in the Keyboard Maestro Field Guide but couldn’t find it.

Contextual Computing is an amazing concept, I’m looking forward to more development of this!

@ismh I am now doing the same. Once I realized that I could import markdown files and could bulk export any notes from Craft in four formats if and when needed, I made Craft my default note taking application. It is also working well as a PKM app. While I like Obsidian, I’m finding Craft more flexible and better suited to my needs. Very impressed so far and the developer, Viktor, has been helpful and responsive.

There is a minimize all command but tactically use the close specific app command. :slight_smile:

1 Like

Fascinating episode as always. Just a quick note on how I’m using MIDI triggers with BetterTouchTool, Keyboard Maestro, and HomeKit on my Mac.

A few of the knobs on my M-Audio keyboard typically go unused, so I’ve assigned BTT “Value Changed” triggers - which run AppleScript to invoke Keyboard Maestro to send hotkeys to the “Homie” (Menubar app) to control the brightness of the left and right desk lamps.

Homie (or HomeControl) allows you to assign individual hotkeys to Scenes - though HomeControl throws an alert if you send keystrokes faster than it can respond.

@MacSparky said he uses 1Password to generate fake UUIDs for notes.

I need to make UUIDs all the time for work. Fortunately Mac OS X ships with /usr/bin/uuidgen which can help with that.

To turbo charge this, just add a TextExpander snippet, and set the content to Shell Script:

#!/bin/bash
/user/bin/uuidgen

Saves me a lot of time!

11 Likes

Thanks @knowuh. I didn’t know about that. New toy!

2 Likes

Very cool. I didn’t know about this either. Inspired by your Text Expander snippet, I made an Alfred Workflow to do the same thing. I put it here: https://github.com/ethanweed/Alfred-make-UUID

1 Like

@Aaron_Antcliff I’d love to see your workflow on this - I’m still trying to get my head around just how to surface these connections effectively.

I use a TextExpander snipped to make Zettelkasten numbers as unique ids - YYYYMMDDHHMMSS

3 Likes

After some back and forth (since Catalina’s Notes AppleScript brook), Hook [generates URLs for notes based on their date-time stamps]( Using Hook with Apple Notes – Hook). Apple doesn’t directly expose the Notes URLs, but I am hopeful they will follow the trend towards exposing links in a helpful manner.

1 Like

oops, I hadn’t read down so far when I posted my comments above on same.

1 Like

well, as we’re on the topic of hook://file// URLs, another distinctive feature of course is that hook://file// can be shared with others (e.g., in Git, SVN, Dropbox, etc.). You can even email the file to someone along with a link. They can move the file around and still use the link. Those cases require the last part of the pathname to be the same. We tweak the algorithms over time to optimize robustness. Hook also supports deep linking of PDFs, so you can point deeply into the PDF (interchangeably with Skim, PDFpenPro and soon Adobe Acrobat). etc.

Same here, not sure what difference there is between the uuid scripting option, and generating these date specific ones, other than that you can sort the latter?