sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

.cbcp (1388B)


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