2019-06-20 08:45:24 +00:00
|
|
|
#!/usr/bin/env sh
|
2019-03-20 16:20:56 +00:00
|
|
|
|
2019-05-26 02:06:24 +00:00
|
|
|
# Description: Show diff of 2 directories or multiple files in vimdiff
|
2019-03-20 16:20:56 +00:00
|
|
|
#
|
2019-06-20 08:45:24 +00:00
|
|
|
# Shell: POSIX compliant
|
2019-03-20 16:20:56 +00:00
|
|
|
# Author: Arun Prakash Jana
|
|
|
|
|
2019-06-03 13:10:29 +00:00
|
|
|
selection=~/.config/nnn/.selection
|
2019-05-26 02:06:24 +00:00
|
|
|
|
2019-06-03 13:10:29 +00:00
|
|
|
if [ -s $selection ]; then
|
2019-06-20 08:45:24 +00:00
|
|
|
arr=$(tr '\0' '\n' < "$selection")
|
|
|
|
if [ "$(echo "$arr" | wc -l)" -gt 1 ]; then
|
|
|
|
f1="$(echo "$arr" | sed -n '1p')"
|
|
|
|
f2="$(echo "$arr" | sed -n '2p')"
|
|
|
|
if [ -d "$f1" ] && [ -d "$f2" ]; then
|
|
|
|
dir1=$(mktemp "${TMPDIR:-/tmp}"/nnn-$(basename "$f1").XXXXXXXX)
|
|
|
|
dir2=$(mktemp "${TMPDIR:-/tmp}"/nnn-$(basename "$f2").XXXXXXXX)
|
|
|
|
ls -A1 "$f1" > "$dir1"
|
|
|
|
ls -A1 "$f2" > "$dir2"
|
|
|
|
vimdiff "$dir1" "$dir2"
|
|
|
|
rm "$dir1" "$dir2"
|
|
|
|
else
|
|
|
|
cat $selection | xargs -0 vimdiff
|
|
|
|
fi
|
2019-06-03 13:10:29 +00:00
|
|
|
else
|
2019-06-20 08:45:24 +00:00
|
|
|
echo "needs at least 2 files or directories selected for comparison"
|
2019-06-03 13:10:29 +00:00
|
|
|
fi
|
2019-05-26 02:06:24 +00:00
|
|
|
fi
|