]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix directory view with viuimg
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 29 Sep 2019 03:49:44 +0000 (09:19 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 29 Sep 2019 03:49:44 +0000 (09:19 +0530)
plugins/viuimg

index 8505be8b4b131107759333c676319f06d067fefc..26597207162dfa386507b2cb281f026378b71a33 100755 (executable)
@@ -2,12 +2,25 @@
 
 # Description: View an image or images in a directory in pager
 #
+# Note: While it's very easy to fix this in Bash (sample commented),  with the
+#       current POSIX shell script implementation the unmatched patterns are spewed.
+#       A patch to fix this is highly appreciated.
+#
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
 if ! [ -z "$1" ]; then
     if [ -d "$1" ]; then
-        viu -n "$1"/* 2>/dev/null | less -R
+        cd "$1"
+
+        # Bash implementation
+        # shopt -s nullglob
+        # viu -n *.bmp *.BMP *.gif *.GIF *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG *.svg *.SVG 2>/dev/null | less -R
+
+        for file in *.bmp *.BMP *.gif *.GIF *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG *.svg *.SVG
+        do
+            viu -n "$file" 2>/dev/null
+        done | less -R
     else
         viu -n "$1" | less -R
     fi