Update notes to have an fzf mode

This commit is contained in:
Tony Blyler 2021-09-27 09:50:24 -04:00
parent d4a7aab052
commit 9b0a7e91d5

View file

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