37 lines
896 B
Plaintext
37 lines
896 B
Plaintext
|
#!/usr/bin/env bash
|
||
|
# Read notes files from ~/.configs_pointer/notes
|
||
|
if [[ $1 =~ '-h' ]]; then
|
||
|
printf 'Open notes files from ~/.configs_pointer/notes\n'
|
||
|
exit 0
|
||
|
elif ! [[ -h ~/.configs_pointer ]]; then
|
||
|
cat <<ERR
|
||
|
Pointer to configs not found
|
||
|
Please set up a symlink ~/.config_pointer to the configs directory
|
||
|
ERR
|
||
|
exit 1
|
||
|
elif ! command -v fzf &>/dev/null; then
|
||
|
printf 'Requires fzf\n'
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
|
||
|
# Fzf for notes file
|
||
|
if command -v fd &> /dev/null; then
|
||
|
notes_file=~/.configs_pointer/notes/"$(fd '.md' ~/.configs_pointer/notes -x basename | fzf)"
|
||
|
else
|
||
|
notes_file="$(find ~/.configs_pointer/notes -type f | fzf)"
|
||
|
fi
|
||
|
|
||
|
|
||
|
# Use best available pagenator
|
||
|
if command -v nvim &>/dev/null; then
|
||
|
nvim -R "${notes_file}"
|
||
|
elif command -v vim &>/dev/null; then
|
||
|
vim -R "${notes_files}"
|
||
|
elif command -v bat &>/dev/null; then
|
||
|
bat --paging=always "${notes_file}"
|
||
|
else
|
||
|
less "${notes_file}"
|
||
|
fi
|
||
|
|