Skip to content

Instantly share code, notes, and snippets.

@ChristopherA
Created January 27, 2017 07:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ChristopherA/31750863730f8363fe334ebdb5cf2b37 to your computer and use it in GitHub Desktop.
Save ChristopherA/31750863730f8363fe334ebdb5cf2b37 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# from https://github.com/westurner/dotfiles/tree/develop/scripts
### pbcopy
# Shim to support something like pbcopy on Linux
function pbcopy {
__IS_MAC=${__IS_MAC:-$(test "$(uname -s)" == "Darwin" && echo 'true')}
if [ -n "${__IS_MAC}" ]; then
cat | /usr/bin/pbcopy
exit
else
# copy to selection buffer AND clipboard
cat | xclip -i -sel c -f | xclip -i -sel p
exit
fi
}
if [ -n "${BASH_SOURCE}" ] && [ "$BASH_SOURCE" == "$0" ]; then
pbcopy
fi
#!/usr/bin/env bash
# Shim to support something like pbpaste on Linux
__IS_MAC=${__IS_MAC:-$(test $(uname -s) == "Darwin" && echo 'true')}
if [ -n "${__IS_MAC}" ]; then
/usr/bin/pbpaste ${@}
exit
else
xclip -selection clipboard -o
exit
fi
@vviikk
Copy link

vviikk commented Sep 14, 2018

Thanks :) Added to my dotfiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment