mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
27 lines
640 B
Bash
Executable file
27 lines
640 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Description: Show diff of 2 directories or multiple files in vimdiff
|
|
#
|
|
# Shell: Bash
|
|
# Author: Arun Prakash Jana
|
|
|
|
selection=~/.config/nnn/.selection
|
|
|
|
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
|
|
fi
|