citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

fuzz-reader (547B)


      1 #!/usr/bin/env bash
      2 BOOKS_DIR="${1:-$HOME/docs}"
      3 
      4 set -eou pipefail
      5 
      6 document=$(find "$BOOKS_DIR" \( -iname '*.txt' -o -iname '*.epub' -o -iname '*.pdf' -o -iname '*.djvu' -o -iname '*.md' -o -iname '*.mediawiki' \) -type f -printf '%T@\t%f\t%p\n' |
      7   sort -rn |
      8   cutt -f2- |
      9   ct |
     10   fzf |
     11   awk '{print $2}')
     12 
     13 name="$(basename "$document")"
     14 noext="${name%.*}"
     15 
     16 #wname "$noext"
     17 ext="$(extname "$document")"
     18 if [ "$ext" == ".txt" ] || [ "$ext" == ".md" ] || [ "$ext" == ".mediawiki" ]; then
     19 	echo lessr "$document"
     20 else
     21 	echo open "$document"
     22 fi