Zettelkasten Forum


Poor Man's Roam-Style Contextual Backlinks (Keyboard Maestro)

When this script is triggered, it creates a new note with all paragraphs that contain the search term, with a link to original document. It's very helpful when I'm trying to get a quick overview of what I've said about a topic.

Probably easier to see a visual. So this query (in the KM Marco):

Produces this file:

Here's the macro:


You of course need to update the path to your Zettelkasten Notes Folder.

Download Macro

Hope it's helpful to somebody.

Comments

  • Sweet! Mind posting it to the macro collection thread with a short description? https://forum.zettelkasten.de/discussion/213/the-archive-keyboard-maestro-alfred-macros

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

  • edited February 4

    VERY nice, though I will have to change "buffer" or it will drive me nuts. But each to their own! Thank you for posting this.

    Edit: though I find that on my machine it does not produce any results. Will have to investigate. I'm presently on Catalina, which might be part of the problem. It seems to break all sorts of stuff.

    Post edited by MartinBB on
  • @MartinBB I had the same reaction. Sounds great but it showed nothing in the note. A few small changes and its work wonderful.

    1. Had to brew install findutils to get gxargs
    2. Had to be sure gxargs is in Keyboard Maestro's path - path added to Keyboard Maestro variable 'ENV_PATH` = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
    3. Still investigating the 2 sed commands. I'd like to have the [[202001261947 Broken Top Reviewed]] transformed into [[202001261947]] Broken Top Reviewed

    Will Simpson
    kestrelcreek.com

  • Meh, I know there's a way to do this in just one sed with multiple capture groups, but how escapes me at the moment. Hackish solution:

    echo "[[202001261947 Broken Top Reviewed]]" | sed 's/\[\[\([0-9]*\) /[[\1]] /g' | sed 's/\]\]$//'
    
  • @msteffens provided this a while ago in https://forum.zettelkasten.de/discussion/comment/3372#Comment_3372

    Adding the title back after the link with another capture group:

    ls | sed -E -e 's/.[^.]*$//' -e 's!^([0-9]+)[[:space:]-]+(.+)![[\1]] \2!' 
    

    Instead of the ls as input, you take the previous macro step.

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

  • @ctietze said:
    Sweet! Mind posting it to the macro collection thread with a short description? https://forum.zettelkasten.de/discussion/213/the-archive-keyboard-maestro-alfred-macros

    Yes absolutely!

  • @Will said:
    @MartinBB I had the same reaction. Sounds great but it showed nothing in the note. A few small changes and its work wonderful.

    1. Had to brew install findutils to get gxargs
    2. Had to be sure gxargs is in Keyboard Maestro's path - path added to Keyboard Maestro variable 'ENV_PATH` = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

    Totally spaced about gxargs, you're exactly right, apologies and thanks for pointing this out.

  • @mleo2003 said:
    Meh, I know there's a way to do this in just one sed with multiple capture groups, but how escapes me at the moment.

    Did you just 'Meh' my beautiful script?! Kidding. The sed command is obviously much simpler but I wanted the contents of my 'search results note' to be sorted by "Title, Z First" so the results would be in the same sort order as my archive.

Sign In or Register to comment.