xclip-img.sh 456 B

1234567891011121314
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. # input=$1
  4. # mimetype=$(file -b --mime-type "$input")
  5. # xclip -selection clipboard -t "$mimetype" -i "$input"
  6. # # xclip -selection clipboard -t "$mimetype" < "$input"
  7. command -v xclip >/dev/null 2>&1 || { echo "Need command xclip. Aborting." >&2; exit 1; }
  8. [[ -f "$1" ]] || { echo "Error: Not a file." >&2; exit 1; }
  9. TYPE=$(file -b --mime-type "$1")
  10. xclip -selection clipboard -t "$TYPE" < "$1"