Last active
March 29, 2022 09:10
-
-
Save uncomfyhalomacro/05852386680cd507f258048806cfeeab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Uses fd - https://github.com/sharkdp/fd | |
# Uses epub2txt2 - https://github.com/kevinboone/epub2txt2 | |
# Uses pdftotext from poppler | |
DOC="$HOME/Documents" | |
export DOC | |
tmp_pdf_file="$(mktemp)" | |
export tmp_pdf_file | |
book="$(fd -p "${DOC}" -e ".pdf" -e ".epub" -0 | xargs -0 sh -c 'for f; do echo "${f#"./Documents/"}"; done' | fzf --sync -e -i --prompt='read book: ' --preview ' | |
tmpstuff={} | |
if [ "${tmpstuff: -4}" = ".pdf" ] | |
then | |
pdftotext "$HOME/Documents/$tmpstuff" "$tmp_pdf_file" | |
else | |
epub2txt "$HOME/Documents/$tmpstuff" > "$tmp_pdf_file" | |
fi | |
bat ${tmp_pdf_file} -p | |
')" | |
export book | |
rm "${tmp_pdf_file}" | |
[ -z "${book}" ] && exit | |
command="zathura \"${DOC}/${book}\"" | |
setsid /bin/sh -c "${command}" & | |
sleep 0.3s | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment