dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

clp (817B)


      1 #!/bin/sh
      2 # clp - Cross-platform (cl)ipboard (p)aste
      3 #
      4 #   clp   - writes clipboard's contents to stdout
      5 #
      6 #   clp | <command>    - pastes contents and pipes it to another process
      7 #
      8 #   clp > <file>      - paste contents to a file
      9 #
     10 # Examples:
     11 #
     12 #   # Pipe to another process
     13 #   clp | grep foo
     14 #
     15 #   # Paste to a file
     16 #   clp > file.txt
     17 os=$(uname -s | tr '[:upper:]' '[:lower:]')
     18 case "$os" in
     19   linux*)
     20     if command -v xclip 1>/dev/null 2>&1; then
     21       xclip -out -selection clipboard
     22     elif command -v xsel 1>/dev/null 2>&1; then
     23       xsel --clipboard --output
     24     else
     25       printf "clc: xclip/xsel not installed\n"
     26     fi
     27     ;;
     28   darwin*)
     29     pbpaste
     30     ;;
     31   msys*|cygwin*|mingw*|nt|win*)
     32     cat /dev/clipboard
     33     ;;
     34   *)
     35     printf "Operating system %s is unknown.\n" "$os"
     36     return 1
     37     ;;
     38 esac