Skip to content

Instantly share code, notes, and snippets.

@wojas
Created November 22, 2018 07:05
Show Gist options
  • Save wojas/857141859d377f6fa74a326263f4a344 to your computer and use it in GitHub Desktop.
Save wojas/857141859d377f6fa74a326263f4a344 to your computer and use it in GitHub Desktop.
I replaced nvALT for note taking with this short shell script and fzf
#!/usr/bin/env bash
# When called with a name, open a specific note.
# When called without a name, use fzf to interactively search notes.
# (fzf: https://github.com/junegunn/fzf)
set -e
cd ~/path/to/my/notes/
export EDITOR=nvim
if [ ! -z "$1" ]; then
"$EDITOR" "$1.md"
exit
fi
main() {
previous_file="$1"
file_to_edit=`select_file $previous_file`
if [ -n "$file_to_edit" ] ; then
"$EDITOR" "$file_to_edit"
main "$file_to_edit"
fi
}
select_file() {
given_file="$1"
fzf --preview="cat {}" --preview-window=right:70%:wrap --query="$given_file"
}
main ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment