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.
 
 
 
 
 
 

67 lignes
1.8 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. # `imvr` is often callable as `imv` on Linux distros
  40. # You might need to change the reference below
  41. elif which imvr >/dev/null 2>&1; then
  42. if [ -f "$1" ]; then
  43. view_dir imvr "$1" >/dev/null 2>&1 &
  44. elif [ -d "$1" ] || [ -h "$1" ]; then
  45. imvr "$1" >/dev/null 2>&1 &
  46. fi
  47. elif which sxiv >/dev/null 2>&1; then
  48. if [ -f "$1" ]; then
  49. view_dir sxiv "$1" >/dev/null 2>&1 &
  50. elif [ -d "$1" ] || [ -h "$1" ]; then
  51. sxiv -qt "$1" >/dev/null 2>&1 &
  52. fi
  53. elif which viu >/dev/null 2>&1; then
  54. viu -n "$1" | less -R
  55. else
  56. printf "Please install imv/sxiv/viu and check their callable names match the plugin source"
  57. read -r _
  58. exit 2
  59. fi