My build of nnn with minor changes
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

imgview 1.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env sh
  2. # Description: Open images in hovered directory and thumbnails
  3. # open hovered image in sxiv or viu and browse other images in the directory
  4. # Dependencies: imv (https://github.com/eXeC64/imv) or,
  5. # sxiv (https://github.com/muennich/sxiv) or,
  6. # viu (https://github.com/atanunq/viu), less
  7. #
  8. # Shell: POSIX compliant
  9. # Author: Arun Prakash Jana
  10. abspath() {
  11. case "$1" in
  12. /*) printf "%s\n" "$1";;
  13. *) printf "%s\n" "$PWD/$1";;
  14. esac
  15. }
  16. listimages() {
  17. find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \
  18. '.*\(jpe?g\|bmp\|webp\|png\|gif\)$' -print0 | sort -z
  19. }
  20. view_dir() {
  21. target="$(abspath "$2")"
  22. count="$(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)"
  23. if [ -n "$count" ]; then
  24. listimages | xargs -0 "$1" -n "$count" --
  25. else
  26. shift
  27. "$1" -- "$@" # fallback
  28. fi
  29. }
  30. if [ -z "$1" ] || ! [ -s "$1" ]; then
  31. printf "empty file"
  32. read -r _
  33. exit 1
  34. fi
  35. if command -v imvr >/dev/null 2>&1; then
  36. if [ -f "$1" ]; then
  37. view_dir imvr "$1" >/dev/null 2>&1 &
  38. elif [ -d "$1" ] || [ -h "$1" ]; then
  39. imvr "$1" >/dev/null 2>&1 &
  40. fi
  41. elif command -v sxiv >/dev/null 2>&1; then
  42. if [ -f "$1" ]; then
  43. view_dir sxiv "$1" >/dev/null 2>&1 &
  44. elif [ -d "$1" ] || [ -h "$1" ]; then
  45. sxiv -qt "$1" >/dev/null 2>&1 &
  46. fi
  47. elif command -v viu >/dev/null 2>&1; then
  48. viu -n "$1" | less -R
  49. else
  50. printf "install imv/sxiv/viu"
  51. read -r _
  52. exit 2
  53. fi