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.
 
 
 
 
 
 

45 lines
930 B

  1. #!/usr/bin/env sh
  2. # Description: Provides drag and drop window for files.
  3. #
  4. # Files that are dropped will be added to nnn's selection
  5. # Some web based files will be downloaded to current directory with curl
  6. # and it may overwrite some existing files
  7. #
  8. # The user has to press mm to clear nnn's selection first
  9. #
  10. # Dependency: https://github.com/mwh/dragon
  11. # Shell: POSIX compliant
  12. # Author: 0xACE
  13. selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
  14. dnd()
  15. {
  16. if which dragon-drag-and-drop; then
  17. dragon-drag-and-drop "$@"
  18. else
  19. dragon "$@"
  20. fi
  21. }
  22. function add_file() {
  23. echo -n "$@" >> "$selection"
  24. echo -ne "\0" >> "$selection"
  25. }
  26. echo -n > "$selection"
  27. # which dnd
  28. # upstream calls it dragon
  29. dnd --print-path --target | while read f
  30. do
  31. if echo -n "$f" | grep '^\(https\?\|ftps\?\|s\?ftp\):\/\/' ; then
  32. curl -LJO "$f"
  33. add_file "$PWD/$(basename "$f")"
  34. elif [ -e "$f" ]; then
  35. add_file "$f"
  36. fi
  37. done &