Last active
March 19, 2017 22:30
-
-
Save ivanalejandro0/fc918ddce0df882c7ad70b134da4a5b3 to your computer and use it in GitHub Desktop.
Multi platform clipboard helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Credit: | |
# original idea from https://github.com/rfairburn | |
clipboard() { | |
case "${OSTYPE}" in | |
linux*) | |
if which xsel &>/dev/null; then | |
xsel --input --clipboard | |
elif which xclip &>/dev/null; then | |
xclip -selection "clipboard" | |
else | |
echo "No clipboard utility!" >&2 | |
return 1 | |
fi | |
;; | |
darwin*) | |
if which pbcopy &>/dev/null; then | |
pbcopy | |
else | |
echo "No clipboard utility!" >&2 | |
return 1 | |
fi | |
;; | |
cygwin*) | |
cat > /dev/clipboard | |
;; | |
*) | |
echo "No clipboard utility!" >&2 | |
return 1 | |
;; | |
esac | |
} | |
clipboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment