Skip to content

Instantly share code, notes, and snippets.

@hbjydev
Last active May 15, 2022 17:04
Show Gist options
  • Save hbjydev/d57a62d030e347760665d6d486a25439 to your computer and use it in GitHub Desktop.
Save hbjydev/d57a62d030e347760665d6d486a25439 to your computer and use it in GitHub Desktop.
zk - zettelkasten management script (requires ripgrep, neovim, bat and fzf)
#!/bin/bash
set -e
function zk_dir() {
if [[ ! -d $HOME/zet ]]; then
mkdir $HOME/zet
fi
}
function zk_id() {
date +%Y%m%d%k%M%S
}
function zk_new() {
id="$(zk_id)"
zk_dir
nvim $HOME/zet/$id.md
}
function zk_search() {
nvim $(rg -l -i "$@" $HOME/zet/*.md | fzf --preview "bat --color always --style plain {}")
}
if [[ "$1" == "new" ]]; then
# new zettelkasten
zk_new
elif [[ "$1" == "search" ]]; then
# search zettelkasten
zk_search "${@:2}"
else
# no subcommand
echo "zk -- $(tput setaf gray)manage a zettelkasten in ~/zet$(tput sgr0)"
echo ""
echo " new: create new note"
echo " search [keywords]: search through existing zettelkasten"
echo ""
echo "copyright (c) hayden young 2022"
fi
@hbjydev
Copy link
Author

hbjydev commented May 15, 2022

If you wanna use this, chuck it somewhere in $PATH and make it executable, then use zk <new|search> to search through everything. :)

@erichardson-lee
Copy link

Line 38 has a non capitalized name, very sus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment