nnn/plugins/ndiff

27 lines
640 B
Plaintext
Raw Normal View History

2019-05-26 02:06:24 +00:00
#!/usr/bin/env bash
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-05-26 02:06:24 +00:00
# Shell: Bash
2019-03-20 16:20:56 +00:00
# Author: Arun Prakash Jana
selection=~/.config/nnn/.selection
2019-05-26 02:06:24 +00:00
if [ -s $selection ]; then
arr=$(cat $selection | tr '\0' '\n')
{ read -r f1; read -r f2; } <<< "$arr"
if [ -z "$f2" ]; then
exit
fi
if [ -d "$f1" ] && [ -d "$f2" ]; then
vimdiff <(cd "$f1" && find | sort) <(cd "$f2" && find | sort)
else
cat $selection | xargs -0 -o vimdiff
# For GNU xargs (note: ignoreme takes up $0)
# cat $selection | xargs -0 bash -c '</dev/tty vimdiff "$@"' ignoreme
fi
2019-05-26 02:06:24 +00:00
fi