/*
This script returns a random Letter or Symbol listed in 'characters.
REQUIRES:
- Obsidian: https://obsidian.md
- Obsidian Templater plugin: https://silentvoid13.github.io/Templater/
- Obsidian QuickAdd plugin: https://github.com/chhoumann/quickadd
- Obsidian Luhman plugin: https://www.google.com/search?q=obsidian+luhmann+plugin&newwindow=1
TO USE:
-
Save this in
your-obsidian-vault/scripts
. -
In the Templater plugin settings, choose
scripts
as the folder for user scripts. -
Create a note and paste this in:
<% tp.user.MakeLuhmanID(length) %>
. -
Replace
length
number of random letters you want as an ID. -
Use <% tp.user.RandomLetterGenerator(#) %> to generate a Luhman inspired ID any length`
-
Templater can also be used with QuickAdd to create a note from a template with a Luhmann style ID.
-
use the 'Temple option in QuickAdd as either a direct command or macro. Include `<% Math.floor((Math.random()*10)+0).toString(16) %><% tp.user.MakeLuhmanID(length) %>0' in the template, not in the template title, to generate a new top level Zettel ID for a Zettelkasten system. This formula can't be pasted into the title because it contains special characters that are not allowed. -This script will return a single letter from characters to use in generation unique IDs. -Use in combination with a random number generator as above to have a #$ starting ID.
-
To work with the Obsidian Luhman plugin, generate only lower case letters. If not using the Luhman plugin you can add uppercase, numbers to the characters var to generate a random ID with a set length and no specific meaning.
-
You can double up alternating between numbers and letters to create a starting Top Level Zettel with 4 characters to increase the number of unique entry points into your Zettelkasten (i.e <% Math.floor((Math.random()*10)+0).toString(16) %><% tp.user.MakeLuhmannID(length) %><% Math.floor((Math.random()*10)+0).toString(16) %><% tp.user.MakeLuhmannID(length) %>0)
*/ function MakeLuhmannID(length) { var result = ''; var characters = 'abcdefghijklmnopqrstuvwxyz'; var charactersLength = characters.length; for ( var i = 0; i < length; i++ ) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } module.exports = MakeLuhmannID;
To use this effectively with the Obsidian Luhman plugin, you want the unique ID to end on a number.
Here is an example:
Entry Zettel using QuickAdd & Templater to create a unique Top level ID:
Templater code created Unique Starting ID
![ZettelkastenEntryPoint00](https://user-images.githubusercontent.com/19896015/200090157-af016603-117c-4c68-933c-7a99710d6720.png)
You must copy and paste it into the Title
![ZettelkastenEntryPoint01](https://user-images.githubusercontent.com/19896015/200090166-af925302-aebb-4921-bdce-f8911d83e013.png)
Then use the Obsidian Luhman Plug in to create Siblings and Child Zettels!
![ZettelkastenEntryPoint02](https://user-images.githubusercontent.com/19896015/200090477-53864ef7-6ecc-483b-b07c-5c52696f14ee.png)
I have QuickAdd ask me for the Central Idea to use as the Title. It also adds it to the note itself.
![ZettelkastenEntryPoint03](https://user-images.githubusercontent.com/19896015/200090426-3af558a5-7eab-4627-94be-1f4655fb6ea1.png)