dots/.bin/fzf-book

25 lines
510 B
Plaintext
Raw Normal View History

2022-05-11 13:55:36 +02:00
#!/usr/bin/env bash
2022-09-22 20:46:42 +02:00
# Generate menu of book filenames and save paths
# Preview window contains metadata
2022-05-11 13:55:36 +02:00
2023-06-14 21:10:38 +02:00
function select_file {
echo "$(find /home/h/doc/books/ -regex '.*\.\(pdf\|epub\|djvu\)' -type f | sort | fzf --delimiter=/ --with-nth=-1)"
}
2022-12-02 13:27:32 +01:00
2023-06-14 21:10:38 +02:00
function open {
if [ -n "$1" ]; then
echo "Opening \"$1\""
zathura "$1" --fork
else
echo "No file selected"
exit 1
fi
}
case "$1" in
--open) open "$(select_file)" ;;
--help) printf "open \n" >&2 ;;
*) open "$(select_file)" ;;
esac