How to populate the search box with text from a command

What I’m trying to do

I’m trying to load a random open task from a hotkey:

  • I can use F1 hotkey to bring up the global search box.
  • I then have to type in “- [ ]” to search for all tasks
  • I then use F2 hotkey for command “open random note from search” (plugin)

What I like to do is automatically populate the search box with “- [ ]”, ideally with a command so I can combine all 3 with a commander macro (plugin) and launch with a new hotkey.

I’ve not used it, just read the description but would possibly the Random To-Do plugin be a better match for you?

It seems to allow you to set a pattern for your todo items, and select either a random file with todo items, or a random todo item.

In case of the regex for an ordinary item, like you showed, I would try: - \[ \]

Disclaimer: I’ve not tried this myself, but it seems like it should fit the bill

1 Like

You could make an Obsidian URL with a search action and…then do some other stuff.

The Obsidian Advanced URI plugin has both a search action and a command action. You’d just need a way to access the URL — maybe via a plugin, or by putting it in a note in a sidebar.

thanks! That’s the perfect solution and your regular expression worked as well. I could assign a hotkey that opens a note with a random task and it puts the cursor at the line with the random task, which is great for notes that have many tasks.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.