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.
 
 
 
 
 
 

65 lignes
1.6 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. # 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 uname | grep -q "Darwin"; then
  36. if [ -f "$1" ]; then
  37. open "$1" >/dev/null 2>&1 &
  38. fi
  39. elif command -v imvr >/dev/null 2>&1; then
  40. if [ -f "$1" ]; then
  41. view_dir imvr "$1" >/dev/null 2>&1 &
  42. elif [ -d "$1" ] || [ -h "$1" ]; then
  43. imvr "$1" >/dev/null 2>&1 &
  44. fi
  45. elif command -v sxiv >/dev/null 2>&1; then
  46. if [ -f "$1" ]; then
  47. view_dir sxiv "$1" >/dev/null 2>&1 &
  48. elif [ -d "$1" ] || [ -h "$1" ]; then
  49. sxiv -qt "$1" >/dev/null 2>&1 &
  50. fi
  51. elif command -v viu >/dev/null 2>&1; then
  52. viu -n "$1" | less -R
  53. else
  54. printf "install imv/sxiv/viu"
  55. read -r _
  56. exit 2
  57. fi