#!/bin/sh

set -o errexit
set -o nounset

if command -v pbpaste >/dev/null 2>&1; then
  exec pbpaste
elif command -v wl-paste >/dev/null 2>&1; then
  WAYLAND_DISPLAY=wayland-0 exec wl-paste --no-newline
elif command -v xclip >/dev/null 2>&1; then
  exec xclip -selection clipboard -o
elif command -v xsel >/dev/null 2>&1; then
  DISPLAY=${DISPLAY:-:0} exec xsel --clipboard --output
elif [ -e /tmp/clipboard ]; then
  exec cat /tmp/clipboard
else
  echo ''
fi
