scripts/send.txtto0x0.sh

43 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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