Skip to content

Instantly share code, notes, and snippets.

@ivanalejandro0
Last active March 19, 2017 22:30
Show Gist options
  • Save ivanalejandro0/fc918ddce0df882c7ad70b134da4a5b3 to your computer and use it in GitHub Desktop.
Save ivanalejandro0/fc918ddce0df882c7ad70b134da4a5b3 to your computer and use it in GitHub Desktop.
Multi platform clipboard helper
#!/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