Add 'dots/' from commit 'f64b634dd8fbb2c8a2898c3b9d0acc9452e4d966'
git-subtree-dir: dots git-subtree-mainline:2ad98cde17git-subtree-split:f64b634dd8
This commit is contained in:
30
dots/.bin/fzf-book
Executable file
30
dots/.bin/fzf-book
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Generate menu of book filenames and save paths
|
||||
# Preview window contains metadata
|
||||
|
||||
function get_book_paths {
|
||||
find /home/h/doc/books/ -regex '.*\.\(pdf\|epub\|djvu\)' -type f | sort
|
||||
}
|
||||
|
||||
function select_file {
|
||||
get_book_paths | fzf --delimiter=/ --with-nth=-1
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
[[ -n "$selected" ]] && xdg-open "$selected" &> /dev/null & disown
|
||||
Reference in New Issue
Block a user