Skip to content

Instantly share code, notes, and snippets.

@yoursdearboy
Last active September 9, 2021 16:00
Show Gist options
  • Save yoursdearboy/6b5d947e15a09db8f2d91c60922ed572 to your computer and use it in GitHub Desktop.
Save yoursdearboy/6b5d947e15a09db8f2d91c60922ed572 to your computer and use it in GitHub Desktop.
#/bin/sh
if [ "$#" -lt 1 ]; then
echo "Usage: clipserver.sh 127.0.0.1 [1234]"
exit
fi
ADDR=$1
if [ "$#" -eq 2 ]; then PORT=$2; else PORT=$RANDOM; fi
echo "Serving clipboard on $ADDR:$PORT"
echo "Press Ctrl-C to terminate"
while true; do pbpaste | nc -l $ADDR $PORT; test $? -gt 128 && break; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment