Generate Zettelkasten ID (timestamp) inline shortcut

Use case

While writing atomic Zettelkasten notes, I often think of related things I also want to make notes on. Since I am using the timestamp-style unique ZK IDs as my naming scheme, it would be nice to have a shortcut which generates the current ID, corresponding to the regex setup in the ZK plugin, and pasts it inline!

Proposed solution

Have a configurable shortcut which pastes the current ZK ID at the cursors location. This would make it very easy to chain notes without having to reach to the sidebar and create a new ZK note with the button.

Current workaround (optional)

Create new ZK note with plugin on sidebar, copy the file name, go back to previous note and insert it there.

Please don’t question the use of unique timestamps as IDs. This is a different topic!!!

3 Likes

Pardon if I misunderstand you, I don’t use ZK, but my own system which bears some similarities as I understand it. I use an ID-based approach to cross-referencing as well, and when I am writing a note and think of a new thought that should go into a new entry in relation to what I’m typing, I generate the ID right then and there while writing, and later go back to create the new entry from that ID. So it sound similar to what you are wanting—but it also sounds like you have no way of generating an ID without the plugin, and thus are having to break up the writing flow to use the software to do so, whenever this happens.

If I’m on the mark, have you considered investing a little time into a text expansion utility? My thinking is that this is the sort of thing you should be able to do everywhere and with great ease, rather than something that depends upon the creation of special purpose features in individual programs—especially if you’re going all in with a system like ZK. You want to be able to insert an ID anywhere at all, at will, whether writing a comment in an HTML file, working in your ToDo list tool or saving a new .md file by hand.

I use a free tool called Espanso, which is fantastic (the developer is friendly and responsive as well) and full of really useful features if you’re technically inclined to investigate them—e.g. you can create your own forms to fill out and generate boilerplate, use shell scripts to generate data, et cetera. It also has a more basic level of usage as well. Inserting dates is one of the more basic things it can do. Here is an example of an Espanso rule that would generate a new ZK ID (I imagine, again I don’t really know the system too well), whenever you type in :zkid:

matches:
  - trigger: ":zkid"
    replace: "{{zk_timestamp}}"
    vars:
      - name: zk_timestamp
        type: date
        params:
          format: "%Y%m%d%H%M"

And now you don’t even really need a prefixer plugin since you can use that in the title bar as well. :slight_smile: But maybe it provides other benefits.

Another approach that might even be better is to make the ZK ID a global variable, then multiple replacements can make use of it—and it keeps the replacement list itself cleaner and easier to browse through. That’s exactly how I go about it. Here’s an example of how that would look:

global_vars:
  - name: zk_timestamp
    type: date
	params:
	  format: "%Y%m%d%H%M"


matches:
  - trigger: ":zkid"
    replace: "{{zk_timestamp}}"
  
  - trigger: ":zklink"
    replace: "[Link Text][{{zk_timestamp}}]"

In this case, we have the same as the above for the first trigger, but we keep the complexity of the variable out of the way since it is defined universally at the top of the file. In the second trigger (:zklink) we demonstrate how to generate a simple Markdown link with a new ZK ID inserted into the target field.

As I say, Espanso is aimed somewhat more at the technical crowd, with its YAML file configuration system. I hear the developer is working on making a simple GUI for configuration in the future, but if you want something more mouse based, there are a number of good options out there. When I used a Mac, my expansion tool of choice was Typinator. It’s not free, but it does all of the above with a GUI.

Once you start using an expansion tool you won’t go back. Like I say, it makes every tool on your computer more powerful, and you’ll start thinking of all kinds of ways you can save yourself time by creating replacements.

3 Likes

I used the same workaround, as you, and ended up creating a template instead using the date override feature.

I have a file/document, in my templates folder, with this as the content: {{date:YYYYMMDDHHmmss}}. When I require an inline timestamp, I press the hotkey to insert a template; type the template name; press enter. Not as quick as the requested shortcut but a bit quicker than: create-copy-paste.

I added something that might work for this in the nldates plugin a little while back:

1 Like