Zettelkasten Forum


Keyboard Maestro - Insert Structure Note link

Hi all!

I'm new to zettelkasten. I've been playing with it for just a few days now, and I've already found some of the KMs very helpful.

Thanks, @Will, for many of them!

I was wondering if anyone had ever created a KM for inserting a link to a structure note on a zettel.

For me, I put my links to the structure note and other zettels at the very bottom of each zettel. I've used the naming convention for structure notes that includes the • between the UID and the text title.

I was thinking if there was a way to set it up so it worked something like this:

  1. I place my cursor in the appropriate location in my zettel.
  2. I enter the key combination for the KM to insert my structure note link.
  3. It then gives me a prompt, asking me which structure note I want to link to (it would limit it to those zettels with the • in the title).
  4. I select the appropriate structure note.
  5. It automatically enters that structure note as a link in the format of UID and text title of the structure note.

Is this possible? Is it unnecessary?

The reverse of this would be a time saver too. For me, I often add a link to my newest zettel to my structure note immediately after I create the zettel. So, if there was a way to go back to my structure note and use a KM to create a link to the most recently created zettel (of even a prompt to choose from one of the more recently created zettels) that would save time too.

Or, have you guys found ways to save time and do this without a KM macro?

Comments

  • Thanks, @mgbianc and welcome to the forums.

    Here is the Keyboard Maestro macro that will add a link to any note from any note.The skill using it comes from simple selection in the prompt.

    In the prompt type, the key and only those zettel with a in the title will populate the selection opportunity. This same macro can be used in the reverse scenario by entering a few numbers represented by the date. For example, 220214 would produce a list of zettel from today. The prompt box does not require the search terms be complete or in order.

    Let me know if you have any problems.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. 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

  • Thanks! I think this may be exactly what I am looking for. I think, though, that I've not got one of the settings right. This is what mine looks like, though I did change the location of my Archive folder.

  • I can duplicate your issue by incorrectly changing the path to my zettelkasten. Please double-check. Please post a "Copy as Image" of the initial action.

    I'll investigate more. It could be an ENV_PATH issue but I don't think so.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. 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

  • I use this path on the Create Note macro, and it works there.

  • edited February 2022

    There's the culprit! That space in the $KMVAR_zettelkastenDirectory variable is the problem. Spaces may work within the Keyboard Maestro environment, but once you start passing Local variables to the Global environment, spaces and not handled uniformly. In experimenting I found d the only solution is to change the name of the directory. Either adding a _ or removing it all together. If you change the name of the directory you will experience a few down stream issues. You'll have to reconnect The Archive with the new file structure and you'll have to change all the other Keyboard Maestro macros that point to the old directory.

    I hope this helps.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. 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

  • I meant to say the problem is in the %Variable%zettelkastenDirectory% which is used by the script as $KMVAR_zettelkastenDirectory.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. 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

  • Thanks! That's helpful. So, that folder is named by iCloud, and I cannot change it. I need to move my directory off of iCloud to fix this, it looks like.

  • Hold on! I may have a solution. I’m in town with the wife and it may take a bit.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. 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

  • Ah, that would be amazing! Will, you are a wonderful ambassador for the zettelkasten. I appreciate your willingness and help to make it as usable as possible.

    When I first began reading about it, I remember reading about the "bearable" aspect of the work. You are doing an amazing job making the "bearable" part more "bearable."

    Much appreciated!

  • I found the solution with the help of Sleepy and ComplexPoint over on the Keyboard Maestro forums. I thought of quoting as a solution, but I focused on the wrong action. With this change, we can have spaces in the pathname.

    In the Execute Shell Script action, double quote the Keyboard Maestro variable like the photo shows. I've fixed the macro if you want to redownload it or you can make the change in situ.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. 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

  • edited February 2022

    Uggh. Okay, the list is populating correctly now, but when I click (double-click, actually) on the note I want, nothing appears in the note where my cursor is.

    I am, apparently, not as tech savvy as I once was...

    I'll keep playing with it. See what I find.

  • What is the format of the file names you are using?
    Likely the regex in the "Search Variable …: action needs tweaking for your setup.
    How many notes do you have so far?

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. 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

  • This is what they look like. I only have 15 notes so far, all on the same structure card because I'm pulling notes from an old notebook.

  • Bingo! A couple of small changes and we should of to the races.
    Look at the image below and change the .md to .txt in the Execute Shell Script action and the regex in the "Search Variable …" action should be (\d{12}) (.*). Let me know how this works.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. 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

  • Bless you, Will! That worked!

  • This is great. I duplicated the macro, changed the keystroke on the duplicate, and was able to modify the formatting of what gets pasted, as I like to have the formatting look one way on my structure note and another way on my zettel.

    Of course, I say that, but I'm only 15 zettel and 1 structure note into it. :)

  • edited February 2022

    @Will Great job!

    You could look into making the file listing more robust:

    sed -E 's/\.(txt|md)$//'
    
    • This will only match path extensions at the end of the file name ($), so I prefer .txt over .md.txt will leave the potential match in the middle intact.
    • This supports multiple alternative extensions, (txt|md). Could of course expand this to (txt|md|markdown|mdown|text) and what have you :)

    Example to verify this works:

    echo "1.txt\n2.md\n3 I prefer .txt over .md.txt\n" | sed -E 's/\.(txt|md)$//'
    

    Author at Zettelkasten.de • https://christiantietze.de/

  • @ctietze Yes! I should have made the macro more diversified to include those that choose to use .txt as the extension for their files. I want to figure out a way to include various file naming conventions. Things like 14 digit UUIDs and UUID Title vs. Title UUID, and I've even seen some files with a UUID and no title. I have no idea how I'd include files with no title.

    There doesn't seem to be much interest, and no one asked for any changes. I suspect that people try the macro, and if it doesn't work right off, they either have the technical skill to solve it or abandon the macro and move on. Either way, I get little feedback to improve the macros. You are the exception, and I appreciate all the encouragement you've given. Maybe this is a developer's dilemma, the struggle to get feedback.

    I've added your suggested improvement and reuploaded the script. It is now available at the original site.

    I envision a new GIT repository in the future. :smile:

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. 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:
    Either way, I get little feedback to improve the macros. You are the exception, and I appreciate all the encouragement you've given. Maybe this is a developer's dilemma, the struggle to get feedback.

    Ah well, that sounds familiar. Most feedback developers get comes from users with errors/bugs/confusion or users who are so happy they explode and just have to share that. Otherwise -- silence. :) It's sometimes better with peers, aka other devs, because they can chip in quick tips when it comes to code. But even super popular open source projects do neither get the funding they deserve nor the participation that would lessen the maintenance burden. It's not always fun, seldom rewarding, but still what many devs enjoy doing :)

    I envision a new GIT repository in the future. :smile:

    Oh yeah, @Sascha and I talked about this in the past already and it sounded like a sensible idea. Requested permissions from folks back then. Need to follow up with some action on the website, though :grimace: (Hard to prioritize at times)

    Author at Zettelkasten.de • https://christiantietze.de/

  • @ctietze said:

    Ah well, that sounds familiar. Most feedback developers get comes from users with errors/bugs/confusion or users who are so happy they explode and just have to share that. Otherwise -- silence. :)

    That's me, honestly! I don't know enough to give real feedback, other than asking for tweaks. In this case, though, I was the errors/bugs/confusion user. Then I was the so happy I almost exploded user. :)

Sign In or Register to comment.