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}" ) }