dotfiles/bin/notes

34 lines
738 B
Plaintext
Raw Normal View History

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