]> Sergey Matveev's repositories - nnn.git/commitdiff
Integrate similar plugins, diff should begin at start of file
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 22 Nov 2019 06:58:55 +0000 (12:28 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 22 Nov 2019 08:20:00 +0000 (13:50 +0530)
plugins/README.md
plugins/getplugs
plugins/nwal [deleted file]
plugins/pywal [deleted file]
plugins/wall [new file with mode: 0755]

index 515b80d4c6ef1d73fca87c7592fdaec613a54a7e..f1146e79b6094d8bd00ac712e1092820ed08adfc 100644 (file)
@@ -35,14 +35,12 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
 | ndiff | Diff for selection (limited to 2 for directories) | sh | vimdiff |
 | nmount | Toggle mount status of a device as normal user | sh | pmount, udisks2 |
 | notes | Open a quick notes file/dir in `$EDITOR` | sh | - |
-| nwal | Set image as wallpaper using nitrogen | sh | nitrogen |
 | oldbigfile | List large files by access time | sh | find, sort |
 | organize | Auto-organize files in directories by file type | sh | file |
 | pastebin | Paste contents of a text a file ix.io | sh | - |
 | pdfview | View PDF file in `$PAGER` | sh | pdftotext/<br>mupdf-tools |
 | picker | Pick files and list one per line (to pipe) | sh | nnn |
 | pskill | Fuzzy list by name and kill process or zombie | sh | fzy, sudo/doas |
-| pywal | Set image as wallpaper, change terminal colorscheme | sh | pywal |
 | readit | Read a PDF or text file aloud | sh | pdftotext, mpv,<br>pico2wave |
 | ringtone | Create a variable bitrate mp3 ringtone from file | sh | date, ffmpeg |
 | splitjoin | Split file or join selection | sh | split, cat |
@@ -55,6 +53,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
 | upgrade | Upgrade nnn manually on Debian 9 Stretch | sh | curl |
 | vidthumb | Show video thumbnails in terminal | sh | [ffmpegthumbnailer](https://github.com/dirkvdb/ffmpegthumbnailer),<br>[lsix](https://github.com/hackerb9/lsix) |
 | viuimg | View an image or images in dir in `$PAGER` | sh | [viu](https://github.com/atanunq/viu), less |
+| wall | Set wallpaper or change colorscheme | sh | nitrogen/pywal |
 
 ## Installing plugins
 
@@ -149,10 +148,10 @@ There are many plugins provided by `nnn` which can be used as examples. Here are
 - Change to arbitrary directory without helper script
     ```sh
     #!/usr/bin/env sh
-    echo -n "cd to: "
-    read dir
+    printf "cd to: "
+    read -r dir
 
-    echo -n "0$dir" > $NNN_PIPE
+    printf "%s" "0$dir" > "$NNN_PIPE"
     ```
 
 ## Contributing plugins
index f7720a877b31eb27179efecb263b192056706bef..3c8d7aa7d99c0c863d3e91ecfa682c1b1f55e3a4 100755 (executable)
@@ -14,7 +14,7 @@ is_cmd_exists () {
 }
 
 merge () {
-       vimdiff "$1" "$2"
+       vimdiff +0 "$1" "$2"
 }
 
 prompt () {
diff --git a/plugins/nwal b/plugins/nwal
deleted file mode 100755 (executable)
index 32d0218..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env sh
-
-# Description: Set the selected image as wallpaper using nitrogen. Just put the cursor on a image and run the script.
-#
-# Shell: POSIX Compliant
-# Author: juacq97
-
-if ! [ -z "$1" ]; then
-    if [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "image" ]; then
-           nitrogen --set-zoom-fill --save "$1"
-# If you want a system notification, uncomment the next 3 lines.
-#           notify-send -a "nnn" "Wallpaper changed!"
-#    else
-#           notify-send -a "nnn" "No image selected"
-    fi
-fi
diff --git a/plugins/pywal b/plugins/pywal
deleted file mode 100755 (executable)
index c8ec867..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env sh
-
-# Description: Set the selected image as wallpaper using pywal and change the terminal color schemes. Just put the cursor on a image and run the script.
-#
-# Shell: POSIX Compliant
-# Author: juacq97
-
-if ! [ -z "$1" ]; then
-    if [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "image" ]; then
-           wal -i "$1"
-# If you want a system notification, uncomment the next 3 lines.
-#           notify-send -a "nnn" "Wallpaper changed!"
-#    else
-#           notify-send -a "nnn" "No image selected"
-    fi
-fi
diff --git a/plugins/wall b/plugins/wall
new file mode 100755 (executable)
index 0000000..0fc6de7
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env sh
+
+# Description: Set the selected image as wallpaper using nitrogen or pywal.
+# Usage: Hover on an image and run the script to set it as wallpaper.
+#
+# Shell: POSIX Compliant
+# Author: juacq97
+
+cmd_exists () {
+       which "$1" > /dev/null 2>&1
+       echo $?
+}
+
+if ! [ -z "$1" ]; then
+    if [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "image" ]; then
+        if [ "$(cmd_exists nitrogen)" -eq "0" ]; then
+               nitrogen --set-zoom-fill --save "$1"
+        elif [ "$(cmd_exists wal)" -eq "0" ]; then
+               wal -i "$1"
+        else
+            printf "nitrogen ir pywal missing"
+            read -r _
+        fi
+
+    # If you want a system notification, uncomment the next 3 lines.
+    # notify-send -a "nnn" "Wallpaper changed!"
+    #   else
+    # notify-send -a "nnn" "No image selected"
+    fi
+fi