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.4 KiB

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