
Pick a top-level folder, land somewhere unexpected. Great for resurfacing dormant notes, rediscovering half-finished ideas, and adding a little serendipity to your SilverBullet workflow.
To activate, paste this command in any page
command.define {
name = "Navigate: Random Page In Subtree",
run = function()
local allPages = space.listPages()
-- collect unique top-level folders
local seen = {}
local prefixes = {}
for _, p in ipairs(allPages) do
local top = p.name:match("^([^/]+/)")
if top and not seen[top] then
seen[top] = true
table.insert(prefixes, { name = top })
end
end
local choice = editor.filterBox("Pick a subtree", prefixes, "name")
if not choice then return end
-- collect all pages under that folder
local filtered = {}
for _, p in ipairs(allPages) do
if p.name:sub(1, #choice.name) == choice.name then
table.insert(filtered, p)
end
end
if #filtered > 0 then
editor.navigate({ page = filtered[math.random(#filtered)].name })
else
editor.flashNotification("No pages under " .. choice.name, "error")
end
end
}
And you can call the command using a button (eg: from home page)
${widgets.commandButton("
Random Page", "Navigate: Random Page In Subtree")}