Zettelkasten Forum


Keyboard Maestro Macro - Search UID in TheArchive from any application

edited November 2019 in The Archive

A thing that I miss when I'm not emacs with zetteldeft is the hotkey which allows for searching whatever UID is under the cursor with deft. So, I tried to replicate it in Keyboard Maestro. It (attempts to) select the current word, then uses the Archive url format to search for that word. Conveniently, if you write your uids like 201911162040 they are a word.

A couple of notes:

  • There doesn't seem to be any way to select text by way of regex or the like in KM. I am selecting text by emulating alt-rightarrow and then shift-alt-leftarrow. This has worked so far in everything I've tried but it seems brittle. Alternate approaches here are welcome.
  • When you are working within The Archive, this also seems to be a mostly functional temporary replacement for a hotkey to "click on" a UID in TheArchive, which I think @ctietze mentioned wanting to implement at some point.
  • I am using the thearchive://match/TERM url format. This should work just as well with thearchive://search/TERM but supply slightly different results. I'm still playing around to figure out which I like better but it's easy to change that in the macro.
  • If you take out the first three steps of the macro, it will work on whatever is in your clipboard. This may be more useful, depending on your workflow.
  • As a bonus, this macro will also search The Archive for whatever word is under your cursor in any other app. Maybe that's good? I could see it being useful if you want to see if you've written about something, or as another way of picking random zetteln.
  • This is the first time I've tried to share a macro, so, let me know if I did anything unfortunate.

Feedback welcome, and Enjoy!

-- S

Link on Dropbox

Comments

  • edited November 2019

    Great! Thanks.

    I've modified a KM macro I use regularly in The Archive to search for highlighted terms. I'm continually looking for ways, tips, tricks - to integrate and connect my notes. Having a quick way to see if and where I have noted a topic in the past to create a connect is super helpful. Expanding this to work everywhere is brilliant. I not sure where I'd run into UID's outside The Archive and most if not all UID's would already be linked. I use this for text searches to facilitate connecting notes.

    Mod I made.
    Modified macro "search the archive for whatever is on your clipboard".
    Had trigger activate with highlighted text. I usually what to search on a couple of terms as in
    Category Theory as opposed to a single search term.

    I no experience with EMACS. It makes me quiver in my boot just thinking about being sucked into the EMACS vortex.

    Will Simpson
    I must keep doing my best even though I'm a failure. My peak cognition is behind me. One day soon I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    kestrelcreek.com

  • @Will said:
    Great! Thanks.

    I've modified a KM macro I use regularly in The Archive to search for highlighted terms. I'm continually looking for ways, tips, tricks - to integrate and connect my notes. Having a quick way to see if and where I have noted a topic in the past to create a connect is super helpful. Expanding this to work everywhere is brilliant. I not sure where I'd run into UID's outside The Archive and most if not all UID's would already be linked. I use this for text searches to facilitate connecting notes.

    I try to sprinkle UIDs liberally throughout my filesystem as a way of making links even outside the Archive. Whenever I get a pdf that goes to research, it is usually renamed something with a UID as the beginning of the filename, and I put UIDs in any text anywhere as a means of linking in a software and filesystem independent way. It works with varying degrees of efficacy depending on the use case.

    By way of example, any given fiction story I've written has a markdown file as its canonical form, and when I need to send it in another format, I just generate that from the markdown. So every story that has notes in the ZK has a YAML block at the top that includes a UID, so I can link it. Also, when I have areas in the novel that connect to the bible I'm making in my ZK I can use UIDs to link from specific sections to the relevant notes, etc.

    I'm trying to develop a software-agnostic system similar to Hook, but I'm not trying too hard, as this is rarely a thing that my work requires. But the ZK is always the central point of this network.

    Mod I made.
    Modified macro "search the archive for whatever is on your clipboard".
    Had trigger activate with highlighted text. I usually what to search on a couple of terms as in
    Category Theory as opposed to a single search term.

    Yeah, I think I'm going to make a second macro that does this.

    I no experience with EMACS. It makes me quiver in my boot just thinking about being sucked into the EMACS vortex.

    As I said elsewhere here, emacs is less a text editor and more a questionable lifestyle choice. It's like Gesamstkunst in text editor form.

  • @Will said:

    Mod I made.
    Modified macro "search the archive for whatever is on your clipboard".
    Had trigger activate with highlighted text. I usually what to search on a couple of terms as in
    Category Theory as opposed to a single search term.

    Quick question, as I try to implement this: how do you url encode your string with spaces? Mine works fine for a single word, but if I try to highlight more than one it throws an error setting the URL, which I think is because there's a space in.

  • @mediapathic I used $KMVAR_tmp as my variable. These Keyboard Maestro variables, once defined, are available for use in the shell. I then executed a shell command "open thearchive://search", quoting the variable, as shown in the photo below. A little different approach. Thanks a lot for this pointer. Being able to search my zettelkasten from anywhere will be a big help.

    This is the link to this Keyboard Maestro macro.

    Will Simpson
    I must keep doing my best even though I'm a failure. My peak cognition is behind me. One day soon I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    kestrelcreek.com

  • @Will said:
    @mediapathic I used $KMVAR_tmp as my variable. These Keyboard Maestro variables, once defined, are available for use in the shell. I then executed a shell command "open thearchive://search", quoting the variable, as shown in the photo below. A little different approach. Thanks a lot for this pointer. Being able to search my zettelkasten from anywhere will be a big help.

    Oh that's a really cool workaround to know. Thank you! And, glad to help.

Sign In or Register to comment.