Skip to content

Instantly share code, notes, and snippets.

@dmarcelino
Forked from elwinar/clip
Created December 1, 2019 17:19
Show Gist options
  • Save dmarcelino/fadc7b06c5a32aaab40988762581f5d0 to your computer and use it in GitHub Desktop.
Save dmarcelino/fadc7b06c5a32aaab40988762581f5d0 to your computer and use it in GitHub Desktop.
Shortcut to pipe from and to clipboard using xclip
#!/bin/bash
# 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
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