From 5441c4f0c8561fe3bad58c48129cb5b66761ed09 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 15 Nov 2016 14:09:14 +0100 Subject: [PATCH] +bin/pb --- bin/pb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 bin/pb diff --git a/bin/pb b/bin/pb new file mode 100755 index 00000000..fe5241f3 --- /dev/null +++ b/bin/pb @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# An OS-agnostic wrapper around the system clipboard (well, for MacOS and +# Linux). + +if [[ -t 0 ]]; then + if command -v xclip >/dev/null; then + xclip -selection clipboard -out + elif command -v xsel >/dev/null; then + xsel --clipboard --output + elif command -v pbpaste >/dev/null; then + pbpaste + else + >&2 echo "No clipboard detected. Aborting." + exit 1 + fi +else + if command -v xclip >/dev/null; then + xclip -selection clipboard -in + elif command -v xsel >/dev/null; then + xsel --clipboard --input + elif command -v pbcopy >/dev/null; then + pbcopy + else + >&2 echo "No clipboard detected. Aborting." + exit 1 + fi +fi +