#!/usr/bin/env bash # Simple daemon which listens for TCP connections and # redirects messages to the local system clipboard. # # This works perfectly fine to forward the local # system clipboard to remote SSH sessions. # # Simon Schürg set -e set -o pipefail if ! [ -x "$(command -v socat)" ]; then echo 'Error: socat is not installed.' >&2 exit 1 fi if ! [ -x "$(command -v xsel)" ]; then echo 'Error: xsel is not installed.' >&2 exit 1 fi # let this script crash if xsel is not working xsel > /dev/null socat -v TCP-LISTEN:5557,fork,bind=localhost EXEC:"xsel --clipboard"