Skip to content

Instantly share code, notes, and snippets.



Created Feb 13, 2015
What would you like to do?
Shortcut to pipe from and to clipboard using xclip
# Linux version
# Use this script to pipe in/out of the clipboard
# Usage: someapp | clip # Pipe someapp's output into clipboard
# clip | someapp # Pipe clipboard's content into someapp
if command -v xclip 1>/dev/null; then
if [[ -p /dev/stdin ]] ; then
# stdin is a pipe
# stdin -> clipboard
xclip -i -selection clipboard
# stdin is not a pipe
# clipboard -> stdout
xclip -o -selection clipboard
echo "Remember to install xclip"

This comment has been minimized.

Copy link

@dmarcelino dmarcelino commented Dec 1, 2019

That makes things simpler. Thanks and well done! 👍

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