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.
 
 
 
 
 
 

51 lignes
1.1 KiB

  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. #
  5. # Shell: POSIX compliant
  6. # Author: Arun Prakash Jana
  7. abspath() {
  8. case "$1" in
  9. /*) printf "%s\n" "$1";;
  10. *) printf "%s\n" "$PWD/$1";;
  11. esac
  12. }
  13. listimages() {
  14. find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \
  15. '.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z
  16. }
  17. sxiv_view_dir() {
  18. target="$(abspath "$1")"
  19. count="$(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)"
  20. if [ -n "$count" ]; then
  21. listimages | xargs -0 sxiv -n "$count" --
  22. else
  23. sxiv -- "$@" # fallback
  24. fi
  25. }
  26. if [ -z "$1" ] || ! [ -s "$1" ]; then
  27. printf "empty file"
  28. read -r _
  29. exit 1
  30. fi
  31. if command -v sxiv >/dev/null 2>&1; then
  32. if [ -f "$1" ]; then
  33. sxiv_view_dir "$1" >/dev/null 2>&1 &
  34. elif [ -d "$1" ] || [ -h "$1" ]; then
  35. sxiv -qt "$1" >/dev/null 2>&1 &
  36. fi
  37. elif command -v viu >/dev/null 2>&1; then
  38. viu -n "$1" | less -R
  39. else
  40. printf "install sxiv or viu"
  41. read -r _
  42. exit 2
  43. fi