Skip to content

Instantly share code, notes, and snippets.

@cjbarroso
Created October 16, 2023 17:37
Show Gist options
  • Save cjbarroso/a91d40c539cd893383729e3b74eed8f1 to your computer and use it in GitHub Desktop.
Save cjbarroso/a91d40c539cd893383729e3b74eed8f1 to your computer and use it in GitHub Desktop.
nvAlt-like bash function to use along with your Obsidian vault to preview and open files quickly
#!/usr/bin/env bash
# Stolen from https://demu.red/blog/2021/04/a-notational-velocity-stopgap-solution-for-linux/
# REQUIRES: `urlencode` command
# Base filesystem dir to search from
BASEDIR="/home/charlie/PARA/3. Recursos/307 Zettelkasten/"
# Name of your vault
VAULTNAME="PARA"
# Url-encoded base dir within the vault to address it using `obsidian://` URLs
# You can use `urlencode` here. Don't forget the last /
BASEVAULT=$(urlencode "3. Recursos/307 Zettelkasten/")
function note() {
pushd "$BASEDIR" 1>/dev/null && \
filename=$(urlencode $(fzf -i --cycle --reverse --preview-window=down --preview='cat {}' --print-query))
xdg-open "obsidian://open?vault=${VAULTNAME}&file=${BASEVAULT}${filename}"
popd 1>/dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment