You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fzbuku 938B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env bash
  2. _video() {
  3. x-terminal-emulator -t mpv -e "mpv '$1'"
  4. }
  5. export -f _video
  6. _open() {
  7. case $1 in
  8. *youtube.com*) _video "$1" ;;
  9. *youtu.be*) _video "$1" ;;
  10. *vimeo.com*) _video "$1" ;;
  11. *) x-www-browser "$1" ;;
  12. esac
  13. }
  14. export -f _open
  15. printf -v jq '.[] | "\(.index) \(.uri) %s\(.tags)%s \(.title)"' "$(tput setaf 7)" "$(tput sgr0)"
  16. main() {
  17. local choice=()
  18. mapfile -t choice < <(buku -p -j |
  19. jq -r "$jq" |
  20. SHELL=bash fzf \
  21. --ansi \
  22. --tac \
  23. --bind='enter:execute: _open {2}' \
  24. --expect='ctrl-d,ctrl-e' \
  25. --delimiter=' ' \
  26. --height=100% \
  27. --no-hscroll \
  28. --preview-window=down \
  29. --preview='buku -p {1}; w3m {2}' \
  30. --query="$*" \
  31. --with-nth=3..)
  32. selection=${choice[@]:1}
  33. case ${choice[0]} in
  34. ctrl-d)
  35. buku -d ${selection[0]%% *}
  36. main
  37. ;;
  38. ctrl-e)
  39. buku -w ${selection[0]%% *}
  40. main
  41. ;;
  42. esac
  43. }
  44. main "$*"