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.

x2sel 1.3 KiB

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