/*
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

You must copy and paste it into the Title

Then use the Obsidian Luhman Plug in to create Siblings and Child Zettels!

I have QuickAdd ask me for the Central Idea to use as the Title. It also adds it to the note itself.
