Open random tagged note from anywhere

When I’m working, I sometimes want to be reminded of what truly matters. Cut through the noise.

I tag certain notes in my vault as #fundamentals.

The following is a fish script that, when run, will open one of these notes.

Note that this is truly random, which means you may get the same note several times in a row (especially if you don’t have many notes with your tag).

Since it is external to Obsidian, it does not require any Obsidian plugins. It does require ripgrep.

function fundamentals
    cd /my/slipbox/path
    set filename (random choice (rg -l '#fundamentals'))
    set escaped (string escape --style=url $filename)
    set url (string join '' 'obsidian://open?vault=slipbox&file=' $escaped)
    open $url

Here is a version of the script that I run using Keyboard Maestro, and then I embed the Keyboard Maestro URL trigger into another vault (my Projects vault, not the slipbox). As a result, I can just click the “fundamentals” link in my daily note template, and a window opens on my screen with a random fundamental note to consider. I can also trigger this from Alfred via Keyboard Maestro.

set -gx PATH $HOME/.rvm/gems/ruby-2.7.1/bin:$HOME/.rvm/gems/[email protected]/bin:$HOME/.rvm/rubies/ruby-2.7.1/bin:$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:$HOME/.rvm/bin
set vault_path $HOME/slipbox
set full_filename (random choice (rg -l '#fundamentals' $vault_path))
set filename (string replace $vault_path '' $full_filename)
set escaped (string escape --style=url $filename)
set url (string join '' 'obsidian://open?vault=slipbox&file=' $escaped)
open $url
1 Like