Skip to content

Instantly share code, notes, and snippets.

@eprev
Forked from guychouk/zetz
Created January 17, 2022 22:24
Show Gist options
  • Save eprev/ba6959da4e73575cfe73f8b88f75a64f to your computer and use it in GitHub Desktop.
Save eprev/ba6959da4e73575cfe73f8b88f75a64f to your computer and use it in GitHub Desktop.
⚡️ Zetz: A script for managing notes in the Zettelkasten method.
#!/usr/bin/env zsh
# _
# _______| |_ ____
# |_ / _ \ __|_ /
# / / __/ |_ / /
# /___\___|\__/___|
#
# The most basic note taking app for the terminal.
#
# Prerequisites:
# - Install tmux, fzf, bat and the_silver_searcher.
# - Set $ZETZ_PATH to the path of your notes directory.
# - Notes should have a .md extention.
# - Notes should have a title on the *first* line prefixed by one hash symbol, i.e. "# Cool Title".
#
# Key Bindings:
# - ctrl-r: reload list
# - ctrl-x: delete note
# - ctrl-i: add new note
#
# NOTE: The new note's name is its creation date in the follwing format: %Y%m%d%H%M%S
pushd $ZETZ_PATH
FZF_DEFAULT_COMMAND="find *.md -type f -exec sed -n 1p {} \; | sed 's_# __g'" \
fzf --height=100% --preview-window=right:65%:wrap \
--preview 'bat --language=md --style=plain --color=always `ag -sl {}`' \
--bind 'enter:execute:$EDITOR `ag -sl {}`' \
--bind 'ctrl-r:reload:$SHELL -c "${FZF_DEFAULT_COMMAND}"' \
--bind 'ctrl-x:execute-silent(rm -f `ag -sl {}`)+reload:$SHELL -c "${FZF_DEFAULT_COMMAND}"' \
--bind 'ctrl-i:execute:tmux split-window "FZF_DEFAULT_COMMAND=\"${FZF_DEFAULT_COMMAND}\" $EDITOR `date +"%Y%m%d%H%M%S"`.md"'
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment