previewer 558 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. draw() {
  3. if which kitten > /dev/null ; then
  4. kitten icat --silent --stdin no --transfer-mode memory --place "${w}x${h}@${x}x${y}" "$1" </dev/null >/dev/tty
  5. exit 1
  6. fi
  7. }
  8. file="$1"
  9. w="$2"
  10. h="$3"
  11. x="$4"
  12. y="$5"
  13. case "$(file -Lb --mime-type "$file")" in
  14. image/*)
  15. draw "$file"
  16. ;;
  17. video/*)
  18. # vidthumb is from here:
  19. # https://raw.githubusercontent.com/duganchen/kitty-pistol-previewer/main/vidthumb
  20. draw "$($ETC/lf/vidthumb "$file")"
  21. ;;
  22. esac
  23. if which bat> /dev/null ; then
  24. pistol "$file" | bat
  25. else
  26. pistol "$file"
  27. fi