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