#!/bin/bash VERSION="0.1.0" SELF="$( basename $0 )" # 20200424 bkw: This used to be a one-line script: # cat "${1:--}" | nc termbin.com 9999 # ...but I really wanted the "copy link to X clipboard" feature. if [ "$1" = "--help" -o "$1" = "-h" ]; then cat < [ ...] Uses nc (netcat) to paste stdin to termbin.com, or pastes one or more files if are given. Spits out paste URL on stdout. Also copies URL to the X clipboard if X is running and either xsel or xclip is installed. Only one paste is created. If you give multiple filenames, they are concatenated together. Written by B. Watson , released under the WTFPL: do WTF you want with this. EOF exit 0 fi # 20251226 bkw: the sed is because termbin.com sends us e.g. # https://termbin.com/XXXX\n\0 # and we get "warning: ignoring null byte" from bash. url="$( cat "${1:--}" | nc termbin.com 9999 | sed 's,\x00,,' )" # 20251227 bkw: don't print an error message if nc fails (nc will print # its own, or the shell will if it's "command not found"). err="$?" [ -z "$url" ] && exit "$err" echo "$url" if [ -n "$DISPLAY" ]; then echo -n "$url" | xsel -i >/dev/null 2>&1 || \ echo -n "$url" | xclip >/dev/null 2>&1 fi exit 0