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.
 
 
 
 
 
 

47 line
1.2 KiB

  1. #!/usr/bin/env sh
  2. # Description: Copy selection to system clipboard as newline-separated entries
  3. # Dependencies:
  4. # - tr
  5. # - xclip/xsel (Linux)
  6. # - pbcopy (macOS)
  7. # - termux-clipboard-set (Termux)
  8. # - clip.exe (WSL)
  9. # - clip (Cygwin)
  10. # - wl-copy (Wayland)
  11. #
  12. # Limitation: breaks if a filename has newline in it
  13. #
  14. # Note: For a space-separated list:
  15. # xargs -0 < "$SELECTION"
  16. #
  17. # Shell: POSIX compliant
  18. # Author: Arun Prakash Jana
  19. IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
  20. selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
  21. if which xsel >/dev/null 2>&1; then
  22. # Linux
  23. tr '\0' '\n' < "$selection" | xsel -bi
  24. elif which xclip >/dev/null 2>&1; then
  25. # Linux
  26. tr '\0' '\n' < "$selection" | xclip -sel clip
  27. elif which pbcopy >/dev/null 2>&1; then
  28. # macOS
  29. tr '\0' '\n' < "$selection" | pbcopy
  30. elif which termux-clipboard-set >/dev/null 2>&1; then
  31. # Termux
  32. tr '\0' '\n' < "$selection" | termux-clipboard-set
  33. elif which clip.exe >/dev/null 2>&1; then
  34. # WSL
  35. tr '\0' '\n' < "$selection" | clip.exe
  36. elif which clip >/dev/null 2>&1; then
  37. # Cygwin
  38. tr '\0' '\n' < "$selection" | clip
  39. elif which wl-copy >/dev/null 2>&1; then
  40. # Wayland
  41. tr '\0' '\n' < "$selection" | wl-copy
  42. fi