My build of nnn with minor changes
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

58 rindas
1.3 KiB

  1. #!/usr/bin/env sh
  2. # Description: Copy system clipboard newline-separated file list to selection
  3. # Requires: tr and
  4. # xclip/xsel (Linux)
  5. # pbpaste (macOS)
  6. # termux-clipboard-get (Termux)
  7. # powershell (WSL)
  8. # cygwim's /dev/clipboard (Cygwin)
  9. # wl-paste (Wayland)
  10. #
  11. # LIMITATION: breaks if a filename has newline in it
  12. #
  13. # Shell: POSIX compliant
  14. # Author: Léo Villeveygoux, after Arun Prakash Jana's .cbcp
  15. IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
  16. SELECTION=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
  17. getclip () {
  18. if which xsel >/dev/null 2>&1; then
  19. # Linux
  20. xsel -bo
  21. elif which xclip >/dev/null 2>&1; then
  22. # Linux
  23. xclip -sel clip -o
  24. elif which pbpaste >/dev/null 2>&1; then
  25. # macOS
  26. pbpaste
  27. elif which termux-clipboard-get >/dev/null 2>&1; then
  28. # Termux
  29. termux-clipboard-get
  30. elif which powershell.exe >/dev/null 2>&1; then
  31. # WSL
  32. powershell.exe Get-Clipboard
  33. elif [ -r /dev/clipboard ] ; then
  34. # Cygwin
  35. cat /dev/clipboard
  36. elif which wl-paste >/dev/null 2>&1; then
  37. # Wayland
  38. wl-paste
  39. fi
  40. }
  41. CLIPBOARD=$(getclip)
  42. # Check if clipboard actually contains a file list
  43. for file in $CLIPBOARD ; do
  44. if [ ! -e "$file" ] ; then
  45. exit 1;
  46. fi
  47. done
  48. printf "%s" "$CLIPBOARD" | tr '\n' '\0' > "$SELECTION"