clc (994B)
1 #!/bin/sh 2 # clc - Cross-platform (cl)ipboard (c)opy 3 # 4 # <command> | clc - copies stdin to clipboard 5 # 6 # clc <file> - copies a file's contents to clipboard 7 # 8 file=$1 9 os=$(uname -s | tr '[:upper:]' '[:lower:]') 10 case "$os" in 11 linux*) 12 if command -v xclip 1>/dev/null 2>&1; then 13 if [ -z "$file" ]; then 14 xclip -in -selection clipboard 15 else 16 xclip -in -selection clipboard "$file" 17 fi 18 elif command -v xsel 1>/dev/null 2>&1; then 19 if [ -z "$file" ]; then 20 xsel --clipboard --input 21 else 22 xsel --clipboard --input < "$file" 23 fi 24 else 25 printf "xclip/xsel not installed\n" 26 fi 27 ;; 28 darwin*) 29 if [ -z "$file" ]; then 30 pbcopy 31 else 32 pbcopy < "$file" 33 fi 34 ;; 35 msys*|cygwin*|mingw*|nt|win*) 36 if [ -z "$file" ]; then 37 cat > /dev/clipboard 38 else 39 cat "$file" > /dev/clipboard 40 fi 41 ;; 42 *) 43 printf "clc: Platform %s not supported.\n" "$os" 44 return 1 45 ;; 46 esac