Obsidian+Plugin REPL Cookbook - 𝕏 - YouTube - Official Obsidian Docs
Plugin REPL is a plugin for Obsidian which allows you to automate tasks in Obsidian by writing JavaScript inside obsidian. I created to allow me to rapidly iterate inside Obsidian while developing plugins, but it generally useful whenever you want to add “a little bit of functionality”. It is inspired by some of the features in Emacs and can be used to quickly hack up features that would otherwise need a plugin. It is also useful when you want to quickly create functionality in Obsidian which needs just a little bit of scripting.
It provides a range of convenience functions to allow you to do things with Obsidian (like read and insert text, open files, append things to files) which would otherwise require a deeper understanding of Obsidian plugins and more work.
For a taster of what can be done in Plugin REPL, using just the following you can create a command to prompt the user for their current mood and write it to a file.
newCommand(async function log_mood() {
let mood = await fuzzySelect(["happy", "sad", "neutral", "angry", "motivated"])
undefined
let timestamp = new Date().toISOString()
appendToFile("mood log", timestamp + " " + mood + "\n")
})
Using Plugin REPL
Plugin REPL consists of three parts:
a means of executing JavaScript from within Obsidian with access to the plugin API
A set of convenience functions for rapid plugin development
The ability to load code at start up.
To use Plugin REPL the first thing you need to do is install it. You can do this manually from the source code or (eventually) via the community plugins feature of the Obsidian.
Once you have this installed Plugin REPL, the first thing you will want to do is evaluate some code. Insert a JavaScript expression, like “1” and then, using the command palette, run “Execute the current line or selection“. (See Executing code).
You may well want to create hotkeys for these commands. I use Ctrl+J to execute this command.
Examples of using Plugin REPL:
I am not affiliated with Obsidian. I am the author of Plugin REPL