dotfiles/bin/notes

34 lines
738 B
Plaintext
Raw Normal View History

2022-09-06 23:34:19 -06:00
#!/usr/bin/env bash
2022-09-07 22:24:18 -06:00
print_help() {
cat <<HELP
Quickly open notes files from ~/.configs_pointer/notes
No arguments required
HELP
}
if [[ -n "$1" ]]; then
print_help
2022-09-06 23:34:19 -06:00
exit 0
elif ! [[ -h ~/.configs_pointer ]]; then
2022-09-07 22:24:18 -06:00
printf 'Please set up a symlink ~/.config_pointer to the configs directory\n'
2022-09-06 23:34:19 -06:00
exit 1
fi
2022-09-07 22:24:18 -06:00
cd ~/.configs_pointer/notes || exit 2
declare -r notes_file="$(fd -e 'md' | fzf)"
2022-09-06 23:34:19 -06:00
# Use best available pagenator
2022-09-07 22:24:18 -06:00
if [[ -z "$notes_file" ]]; then
printf "No note file selected\n"
exit 1
elif command -v nvim &>/dev/null; then
2022-09-06 23:34:19 -06:00
nvim -R "${notes_file}"
elif command -v vim &>/dev/null; then
2022-09-07 22:24:18 -06:00
vim -R "${notes_file}"
2022-09-06 23:34:19 -06:00
elif command -v bat &>/dev/null; then
bat --paging=always "${notes_file}"
else
less "${notes_file}"
fi