@readwithai - X - Blog - Plugin REPL - Cookbook
Plugin REPL in Obsidian lets you script obsidian with JavaScript directly within Obsidian. A common thing to want to do is explore objects to work out how you can use this. Plugin REPL provides a dir and fuzzyDir method for this purpose:dir(app)
fuzzyDir(app)
However, after a while I got bored to typing this. I could have added dot completion like an editor to Plugin REPL, but plugin REPL doesnβt quite βownβ dot in Obsidian - because you can write and execute code anywhere with Plugin REPL.
Instead I quickly hacked up a couple of commands so that I could have a hotkey for looking up and inserting attributes.
newCommand(async function fuzzy_dir_line() {
let attr = await fuzzyDir(eval(lineAtPoint()))
endOfLine()
if (! isNaN(attr)) {
insert("[" + attr + "]")
} else {
insert(".")
insert(attr)
}
})
newCommand( function delete_back_to_dot () {
let end = point()
backwardRegexp(/\./)
kill(point(), end)
})
Then I bind some hotkeys to these.
Hereβs a demo of this working.
This is part of a cookbook of cool things you can do with Obsidian and Plugin REPL.
I am @readwithai. I make tools in Obsidian related to productivity, agency and reading and write about them. If that sounds interesting you can follow me on X or substack.