diff options
author | Krisan Alifari <akrifari@gmail.com> | 2020-04-20 23:49:35 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-20 22:19:35 +0530 |
commit | d549ae748626e648eeca7926569598f8d2653714 (patch) | |
tree | cf1ae692bf3b34efa5b5155176cf64e60c766744 /plugins/diffs | |
parent | 4b5ecbe8fc1d16f11325baf268bf484043e8f531 (diff) | |
download | nnn-d549ae748626e648eeca7926569598f8d2653714.tar.gz |
Add nvim as a diff tool for getplugs plugin (#527)
* Add nvim as a diff tool for getplugs plugin
* Comment out `is_cmd_exists()`
* Add nvim diff tool for diffs plugin
* Add $EDITOR to nuke plugin for editing/reading text file format
* Modify diff command to fix CircleCI failures
* Fix getplugs prompt
* Allow nuke to use custom $PAGER
Diffstat (limited to 'plugins/diffs')
-rwxr-xr-x | plugins/diffs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/plugins/diffs b/plugins/diffs index 71f6817..ff85aa8 100755 --- a/plugins/diffs +++ b/plugins/diffs @@ -12,12 +12,18 @@ selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection +if which nvim >/dev/null 2>&1; then + diffcmd="nvim -d" +else + diffcmd="vimdiff +0" +fi + dirdiff() { dir1=$(mktemp "${TMPDIR:-/tmp}"/nnn-"$(basename "$1")".XXXXXXXX) dir2=$(mktemp "${TMPDIR:-/tmp}"/nnn-"$(basename "$2")".XXXXXXXX) ls -A1 "$1" > "$dir1" ls -A1 "$2" > "$dir2" - vimdiff "$dir1" "$dir2" + $diffcmd "$dir1" "$dir2" rm "$dir1" "$dir2" } @@ -33,14 +39,14 @@ if [ -s "$selection" ]; then # Vim: Warning: Input is not from a terminal # xargs -0 -o vimdiff < $selection - xargs -0 vimdiff +0 < "$selection" + eval xargs -0 "$diffcmd" < "$selection" fi elif ! [ -z "$1" ]; then f1="$(echo "$arr" | sed -n '1p')" if [ -d "$f1" ] && [ -d "$1" ]; then dirdiff "$f1" "$1" elif [ -f "$f1" ] && [ -f "$1" ]; then - vimdiff +0 "$f1" "$1" + $diffcmd "$f1" "$1" else echo "cannot compare file with directory" fi |