plugins/ndiff | 22 +++++++++++++++++----- diff --git a/plugins/ndiff b/plugins/ndiff index 46e829a7a4b615b38227e46f84229db1cc1130bd..e76b151c19d2b86c2efb0b407ec989e33dea3de5 100755 --- a/plugins/ndiff +++ b/plugins/ndiff @@ -5,10 +5,22 @@ # # Shell: Bash # Author: Arun Prakash Jana -arr=($(cat ~/.config/nnn/.selection | tr '\0' '\n')) +selection=~/.config/nnn/.selection + +if [ -s $selection ]; then + arr=$(cat $selection | tr '\0' '\n') + { read -r f1; read -r f2; } <<< "$arr" -if [ -d "${arr[0]}" ] && [ -d "${arr[1]}" ]; then - vimdiff <(cd ${arr[0]} && find | sort) <(cd ${arr[1]} && find | sort) -else - vimdiff "${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 '