My build of nnn with minor changes
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

dragdrop 1.8 KiB

il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env sh
  2. # Description: Open a Drag and drop window, to drop files onto other programs.
  3. # Also provides drag and drop window for files.
  4. #
  5. # Files that are dropped will be added to nnn's selection
  6. # Some webbased files will be downloaded to current directory with curl
  7. # and it may overwrite some existing files
  8. #
  9. # The user has to mm to clear nnn's selection first
  10. #
  11. # Dependency: https://github.com/mwh/dragon
  12. # Shell: POSIX compliant
  13. # Author: 0xACE
  14. selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
  15. resp=f
  16. all=
  17. if which dragon-drag-and-drop >/dev/null 2>&1; then
  18. dnd="dragon-drag-and-drop"
  19. else
  20. dnd="dragon"
  21. fi
  22. add_file ()
  23. {
  24. printf "%s" "$@" >> "$selection"
  25. printf "\0" >> "$selection"
  26. }
  27. use_all ()
  28. {
  29. printf "mark --all (a) [default=none]: "
  30. read -r resp
  31. if [ "$resp" = "a" ]; then
  32. all="--all"
  33. else
  34. all=""
  35. fi
  36. }
  37. if [ -s "$selection" ]; then
  38. printf "Drop file (r). Drag selection (s), Drag current directory (d) or drag current file (f) [default=f]: "
  39. read -r resp
  40. else
  41. printf "Drop file (r). Drag current directory (d) or drag current file (f) [default=f]: "
  42. read -r resp
  43. if [ "$resp" = "s" ]; then
  44. resp=f
  45. fi
  46. fi
  47. if [ "$resp" = "s" ]; then
  48. use_all
  49. sed -z 's|'"$PWD/"'||g' < "$selection" | xargs -0 "$dnd" "$all" &
  50. elif [ "$resp" = "d" ]; then
  51. use_all
  52. "$dnd" "$all" "$PWD/"* &
  53. elif [ "$resp" = "r" ]; then
  54. printf > "$selection"
  55. "$dnd" --print-path --target | while read -r f
  56. do
  57. if printf "%s" "$f" | grep '^\(https\?\|ftps\?\|s\?ftp\):\/\/' ; then
  58. curl -LJO "$f"
  59. add_file "$PWD/$(basename "$f")"
  60. elif [ -e "$f" ]; then
  61. add_file "$f"
  62. fi
  63. done &
  64. else
  65. if [ -n "$1" ] && [ -e "$1" ]; then
  66. "$dnd" "$1" &
  67. fi
  68. fi