From 9b0a7e91d50cfd9e9bcaf7d0e3a781391dddc7a3 Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Mon, 27 Sep 2021 09:50:24 -0400 Subject: [PATCH] Update notes to have an fzf mode --- home/.zshrc.d/notes.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/home/.zshrc.d/notes.sh b/home/.zshrc.d/notes.sh index c7b539c..095dcb8 100755 --- a/home/.zshrc.d/notes.sh +++ b/home/.zshrc.d/notes.sh @@ -2,6 +2,16 @@ notes() { local -r NOTES_DIR="${NOTES_DIR:-${HOME}/notes}" + local -r EDITOR="${EDITOR:-vim}" + local EDITOR_OPTIONS=() + + if [[ "${EDITOR}" =~ 'vim$' ]]; then + EDITOR_OPTIONS=( + '-c' + 'set spell' + ) + fi + for ARG in "$@"; do ( @@ -10,6 +20,10 @@ notes() { cd "$NOTES_DIR" case "${ARG}" in + 'fzf') + "${EDITOR}" "${EDITOR_OPTIONS[@]}" "$(notes ls | fzf)" + ;; + 'ls') ag -g '' -l "${NOTES_DIR}" | sort -hr ;; @@ -56,16 +70,6 @@ notes() { echo -e "# $(date -d "@${NOW}" +'%a %d %b %Y')\n\n## todo\n\n" > "${FILE_PATH}" fi - local -r EDITOR="${EDITOR:-vim}" - local EDITOR_OPTIONS=() - - if [[ "${EDITOR}" =~ 'vim$' ]]; then - EDITOR_OPTIONS=( - '-c' - 'set spell' - ) - fi - "${EDITOR}" "${EDITOR_OPTIONS[@]}" "${FILE_PATH}" ) }