nnn/plugins/ndiff

27 lines
640 B
Text
Raw Normal View History

2019-05-26 07:36:24 +05:30
#!/usr/bin/env bash
2019-03-20 21:50:56 +05:30
2019-05-26 07:36:24 +05:30
# Description: Show diff of 2 directories or multiple files in vimdiff
2019-03-20 21:50:56 +05:30
#
2019-05-26 07:36:24 +05:30
# Shell: Bash
2019-03-20 21:50:56 +05:30
# Author: Arun Prakash Jana
selection=~/.config/nnn/.selection
2019-05-26 07:36:24 +05:30
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 07:36:24 +05:30
fi