From 3709262d0c0b057558d1ab156466309a4ee27d8b Mon Sep 17 00:00:00 2001 From: Gardouille Date: Tue, 10 Mar 2020 21:30:41 +0100 Subject: [PATCH] Script to send content of clipboard to 0x0 service --- send.txtto0x0.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 send.txtto0x0.sh diff --git a/send.txtto0x0.sh b/send.txtto0x0.sh new file mode 100755 index 0000000..5c947c1 --- /dev/null +++ b/send.txtto0x0.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# .. vim: foldmarker=[[[,]]]:foldmethod=marker + +# This script will try to: +## Send the content of the clipboard to a remote file hosting. +## Get the url to access to this content and put it in the clipboard +## in place of the previous content. + +# Vars [[[ +debug="0" + +## Colors [[[ +c_redb='\033[1;31m' +c_magentab='\033[1;35m' +c_reset='\033[0m' +## ]]] + +txt_to_send=$(xclip -out) +null_url="https://null.101010.fr" +content_url="" + +# ]]] + +if [ -n "${txt_to_send}" ]; then + [ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG : xclip to send to ${null_url} : ${txt_to_send}." + + ## Send the text to null pointer service + content_url=$(echo "${txt_to_send}" | curl -F'file=@-;' "${null_url}") + + ## If content was successfully send + if [ -n "${content_url}" ]; then + [ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG : Null pointer to see the content : ${content_url}" + ### Put it on the clipboard + echo "${content_url}" | xclip -rmlastnl -selection clipboard + fi + +else + [ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG : xclip looks empty : ${txt_to_send}." + exit 1 +fi + +exit 0