Skip to content

Instantly share code, notes, and snippets.

@mecab mecab/wpb.sh forked from greymd/wpb.sh
Last active Jan 16, 2017

Embed
What would you like to do?
copy & paste through Web
# Usage
## Example 1 (Text)
# $ echo foobar | wpbcopy
# $ wpbpaste
# foobar
## Example 2 (Binary)
# $ cat image.jpg| wpbcopy
# $ wpbpaste | file -
# /dev/stdin: JPEG image data, JFIF standard 1.01
# Set ID and PASSWORD **AS YOU LIKE**.
MYID="your_id"
PASSWD="your_password"
# Whare the last pasted content stored is.
# It is re-used when you failed to get the remote content.
LASTPASTE_PATH="${TMPDIR}/lastPaste"
wpbcopy () {
local TRANS_URL=$(curl -so- --upload-file <(cat | openssl aes-256-cbc -e -pass pass:$PASSWD) https://transfer.sh/$MYID);
curl -s -X POST "https://cl1p.net/$MYID" --data "content=$TRANS_URL" > /dev/null
}
wpbpaste () {
local TRANS_URL=$(curl -s "https://cl1p.net/$MYID" | xmllint --html --xpath '/html/body/div/div/textarea/text()' -) 2> /dev/null || ""
if [ "$TRANS_URL" = "" ]; then
[ -f "$LASTPASTE_PATH" ] || return 1
echo "(Pasting the last paste)" >&2
cat "$LASTPASTE_PATH" | openssl aes-256-cbc -d -pass pass:$PASSWD
return 0
fi
curl -so- "$TRANS_URL" | tee "$LASTPASTE_PATH" | openssl aes-256-cbc -d -pass pass:$PASSWD
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.