about summary refs log tree commit diff stats
path: root/examples
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2021-08-27 15:35:43 +0600
committerNRK <nrk@disroot.org>2021-08-27 15:35:43 +0600
commitc09d4a846ccf635579ef3cb3e55d20478fb07438 (patch)
treeb832e6a499cd8bd2b4d725ba7eeb4f17065aef2a /examples
parentd39308d95cc34b05f91e5f0386f5a9b69ed525fb (diff)
downloadranger-c09d4a846ccf635579ef3cb3e55d20478fb07438.tar.gz
sxiv-rifle: don't grep non img extension files
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/rifle_sxiv.sh9
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/rifle_sxiv.sh b/examples/rifle_sxiv.sh
index 5b096eaa..15fc914f 100755
--- a/examples/rifle_sxiv.sh
+++ b/examples/rifle_sxiv.sh
@@ -24,6 +24,13 @@ listfiles () {
       '.*\(jpe?g\|bmp\|png\|gif\|webp\)$' -print0 | sort -z
 }
 
+ispic () {
+    case "${1##*.}" in
+        "jpg"|"jpeg"|"bmp"|"png"|"gif"|"webp") return 0 ;;
+        *) return 1 ;;
+    esac
+}
+
 [ "$1" = '--' ] && shift
 case "$1" in
     "") echo "Usage: ${0##*/} PICTURES" >/dev/stderr && exit ;;
@@ -31,7 +38,7 @@ case "$1" in
     *)  target="$PWD/$1" ;;
 esac
 
-[ -f "$target" ] && count="$(listfiles | grep -m 1 -ZznF "$target")"
+ispic "$target" && count="$(listfiles | grep -m 1 -ZznF "$target")"
 
 if [ -n "$count" ]; then
     listfiles | xargs -0 sxiv -n "${count%%:*}" --