My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

36 lines
1.2 KiB

  1. #!/usr/bin/env sh
  2. # Description: Show diff of 2 directories or multiple files in vimdiff
  3. #
  4. # Note: vim may show the warning: 'Vim: Warning: Input is not from a terminal'
  5. # press 'Enter' to ignore and proceed.
  6. #
  7. # Shell: POSIX compliant
  8. # Authors: Arun Prakash Jana, ath3
  9. selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
  10. if [ -s "$selection" ]; then
  11. arr=$(tr '\0' '\n' < "$selection")
  12. if [ "$(echo "$arr" | wc -l)" -gt 1 ]; then
  13. f1="$(echo "$arr" | sed -n '1p')"
  14. f2="$(echo "$arr" | sed -n '2p')"
  15. if [ -d "$f1" ] && [ -d "$f2" ]; then
  16. dir1=$(mktemp "${TMPDIR:-/tmp}"/nnn-"$(basename "$f1")".XXXXXXXX)
  17. dir2=$(mktemp "${TMPDIR:-/tmp}"/nnn-"$(basename "$f2")".XXXXXXXX)
  18. ls -A1 "$f1" > "$dir1"
  19. ls -A1 "$f2" > "$dir2"
  20. vimdiff "$dir1" "$dir2"
  21. rm "$dir1" "$dir2"
  22. else
  23. # If xargs supports the -o option, use it to get rid of:
  24. # Vim: Warning: Input is not from a terminal
  25. # xargs -0 -o vimdiff < $selection
  26. xargs -0 vimdiff +0 < "$selection"
  27. fi
  28. else
  29. echo "needs at least 2 files or directories selected for comparison"
  30. fi
  31. fi