#!/bin/sh -e

# shellcheck disable=SC2248,SC2312
: "${TTY:=$( (tty || tty </proc/${PPID}/fd/0) 2>/dev/null | grep /dev/) }"

# shellcheck disable=SC2249
case "$1" in
  copy)
    buffer=$(base64)
    [ -n "${TTY}" ] && printf '\033]52;c;%s\007' "${buffer}" >"${TTY}"
    ;;
  paste)
    exit 1
    ;;
esac
