aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-05-26 07:36:24 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-05-26 10:27:09 +0530
commitd6fbe87768a0893581e3fbad89c43aa2aa839251 (patch)
treea2c8cf81f15b69e10f364696bbe4e4f74c141bf3 /plugins
parent7bf671c954312f38ab0a457879b9ba159a63bae2 (diff)
downloadnnn-d6fbe87768a0893581e3fbad89c43aa2aa839251.tar.gz
Support directory diff
Diffstat (limited to 'plugins')
-rw-r--r--plugins/README.md2
-rwxr-xr-xplugins/ndiff14
2 files changed, 11 insertions, 5 deletions
diff --git a/plugins/README.md b/plugins/README.md
index bcaedf6..107bf99 100644
--- a/plugins/README.md
+++ b/plugins/README.md
@@ -9,7 +9,7 @@
| imgur | bash | - | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) |
| ipinfo | sh | curl, whois | Fetch external IP address and whois information |
| kdeconnect | sh | kdeconnect-cli | Send selected files to an Android device |
-| ndiff | sh | vimdiff | Show diff for selection |
+| ndiff | bash | vimdiff | Diff for selection (limited to 2 for directories) |
| nmount | sh | pmount | Toggle mount status of a device as normal user |
| nwal | sh | nitrogen | Set the selected image as wallpaper using nitrogen |
| pastebin | sh | [pastebinit](https://launchpad.net/pastebinit) | Paste contents of current (text) file to paste.ubuntu.com |
diff --git a/plugins/ndiff b/plugins/ndiff
index fad28ad..46e829a 100755
--- a/plugins/ndiff
+++ b/plugins/ndiff
@@ -1,8 +1,14 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
-# Description: Show diff using vimdiff
+# Description: Show diff of 2 directories or multiple files in vimdiff
#
-# Shell: POSIX compliant
+# Shell: Bash
# Author: Arun Prakash Jana
-vimdiff $(cat ~/.config/nnn/.selection | tr '\0' '\n')
+arr=($(cat ~/.config/nnn/.selection | tr '\0' '\n'))
+
+if [ -d "${arr[0]}" ] && [ -d "${arr[1]}" ]; then
+ vimdiff <(cd ${arr[0]} && find | sort) <(cd ${arr[1]} && find | sort)
+else
+ vimdiff "${arr[@]}"
+fi