Skip to content

Instantly share code, notes, and snippets.

@holiman
Created September 25, 2018 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holiman/067037a959d7c175a8ee2b4c61bd854a to your computer and use it in GitHub Desktop.
Save holiman/067037a959d7c175a8ee2b4c61bd854a to your computer and use it in GitHub Desktop.
best script ever, place it as `~/bin/clip`
#!/bin/bash
# Linux version
# Use this script to pipe in/out of the clipboard
#
# Usage: someapp | clipboard # Pipe someapp's output into clipboard
# clipboard | 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
else
# stdin is not a pipe
# clipboard -> stdout
xclip -o -selection clipboard
fi
else
echo "Remember to install xclip"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment