sclip

shitty clipboard
git clone git://git.ckyln.com/~cem/sclip.git
Log | Files | Refs | README | LICENSE

sclip (667B)


      1 #!/bin/sh
      2 
      3 # Dumb clipboard manager for tty
      4 
      5 usage() { printf "USAGE: ${0##*/} -p[rint]|-d[elete]|-o[ut]|-h[elp]\\nSee README for more info\\n"; exit 1; }
      6 
      7 [ "$1" = "-h" ] || [ "$1" = "--help" ] && usage
      8 mkdir -p "$HOME/.cache"  # Create cache directory if it doesn't exist
      9 while getopts ':pdo' args; do case $args in
     10 		p) cat "$HOME/.cache/clipboard"; exit ;;  # Print clipboard
     11 		d) :> "$HOME/.cache/clipboard"; exit ;;   # Delete clipboard
     12 		o) stdout="1" ;;                          # Print stdin to stdout
     13 		?) printf "${0##*/}: invalid option -- $OPTARG\\n" ; exit 1 ;; esac; done
     14 cat > "$HOME/.cache/clipboard"
     15 [ -z "$stdout" ] || cat "$HOME/.cache/clipboard"