]> Sergey Matveev's repositories - nnn.git/commitdiff
Merge plugins imgsxiv and imgviu
authorArun Prakash Jana <engineerarun@gmail.com>
Thu, 2 Jan 2020 18:57:28 +0000 (00:27 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Thu, 2 Jan 2020 18:57:28 +0000 (00:27 +0530)
plugins/README.md
plugins/imgsxiv [deleted file]
plugins/imgview [new file with mode: 0755]
plugins/imgviu [deleted file]

index 3f8fc4b4c17d2dfaabbd8e427f10e9013d09bcd8..0a23369bc52ba31db3eb358aba6d84056c61548e 100644 (file)
@@ -27,10 +27,9 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
 | gutenread | Browse, download, read from Project Gutenberg | sh | curl, unzip, w3m<br>[epr](https://github.com/wustho/epr) (optional) |
 | hexview | View a file in hex in `$PAGER` | sh | xxd |
 | imgresize | Resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) |
-| imgsxiv | Browse images, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)), [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images)| sh | sxiv |
 | imgthumb | View thumbnail of an image or dir of images | sh | [lsix](https://github.com/hackerb9/lsix) |
 | imgur | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) | bash | - |
-| imgviu | View an image or images in dir in `$PAGER` | sh | [viu](https://github.com/atanunq/viu), less |
+| imgview | Browse images, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)), [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images)| sh | sxiv/[viu](https://github.com/atanunq/viu), less|
 | ipinfo | Fetch external IP address and whois information | sh | curl, whois |
 | kdeconnect | Send selected files to an Android device | sh | kdeconnect-cli |
 | launch | GUI application launcher | sh | fzf/fzy |
diff --git a/plugins/imgsxiv b/plugins/imgsxiv
deleted file mode 100755 (executable)
index cbe4a18..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env sh
-
-# Description: Open images in hovered  directory and thumbnails
-#              open hovered image in sxiv and browse other images in the directory
-#
-# Shell: POSIX compliant
-# Author: Arun Prakash Jana
-
-if command -v sxiv >/dev/null 2>&1; then
-    if ! [ -z "$1" ]; then
-        if [ -f "$1" ]; then
-            sxiv -q "$1" "$PWD"
-        elif [ -d "$1" ] || [ -h "$1" ]; then
-            sxiv -qt "$1"
-        fi
-    fi
-else
-    echo "sxiv missing"
-    read -r _
-fi
diff --git a/plugins/imgview b/plugins/imgview
new file mode 100755 (executable)
index 0000000..dc4d3a4
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/env sh
+
+# Description: Open images in hovered  directory and thumbnails
+#              open hovered image in sxiv or viu and browse other images in the directory
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+if [ -z "$1" ] || ! [ -s "$1" ]; then
+    printf "empty file"
+    read -r _
+    exit 1
+fi
+
+if command -v sxiv >/dev/null 2>&1; then
+    if [ -f "$1" ]; then
+        sxiv -q "$1" "$PWD"
+    elif [ -d "$1" ] || [ -h "$1" ]; then
+        sxiv -qt "$1"
+    fi
+elif command -v viu >/dev/null 2>&1; then
+    viu -n "$1" | less -R
+else
+    printf "install sxiv or viu"
+    read -r _
+    exit 2
+fi
diff --git a/plugins/imgviu b/plugins/imgviu
deleted file mode 100755 (executable)
index 200a459..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env sh
-
-# Description: View an image or images in a directory in $PAGER
-#
-# Shell: POSIX compliant
-# Author: Arun Prakash Jana
-
-if ! [ -z "$1" ]; then
-    viu -n "$1" | less -R
-fi