2016-11-15 05:09:14 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# An OS-agnostic wrapper around the system clipboard (well, for MacOS and
|
|
|
|
# Linux).
|
|
|
|
|
|
|
|
if [[ -t 0 ]]; then
|
|
|
|
if command -v xclip >/dev/null; then
|
2017-04-25 18:57:49 -07:00
|
|
|
xclip -display :0 -selection clipboard -out
|
2016-11-15 05:09:14 -08:00
|
|
|
elif command -v xsel >/dev/null; then
|
|
|
|
xsel --clipboard --output
|
|
|
|
elif command -v pbpaste >/dev/null; then
|
|
|
|
pbpaste
|
|
|
|
else
|
|
|
|
>&2 echo "No clipboard detected. Aborting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if command -v xclip >/dev/null; then
|
2017-04-25 18:57:49 -07:00
|
|
|
xclip -display :0 -selection clipboard -in
|
2016-11-15 05:09:14 -08:00
|
|
|
elif command -v xsel >/dev/null; then
|
|
|
|
xsel --clipboard --input
|
|
|
|
elif command -v pbcopy >/dev/null; then
|
|
|
|
pbcopy
|
|
|
|
else
|
|
|
|
>&2 echo "No clipboard detected. Aborting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|