Created
July 19, 2018 08:38
-
-
Save PsychoTea/1d2ff0db968f3b700f306fea76cb63eb to your computer and use it in GitHub Desktop.
A script which takes input from STDIN and creates a pastie on ghostbin.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
lang=text | |
# See if language arg is given | |
if [ "$#" -eq "1" ]; then | |
lang=$1 | |
fi | |
echo "Using language: $lang" | |
STDIN=$(cat -) | |
echo "Uploading to Ghostbin..." | |
# POST https://ghostbin.com/paste/new | |
# FORM DATA | |
# lang: text | |
# text: the actual text stuff | |
# expire: -1 | |
# password: | |
# title: | |
curl -s \ | |
-D /tmp/headers.txt \ | |
-X POST \ | |
-F "lang=$lang" \ | |
-F "text=$STDIN" \ | |
-F "expire=-1" \ | |
-F "password=" \ | |
-F "title=" \ | |
https://ghostbin.com/paste/new | |
location_header=$(cat /tmp/headers.txt | grep "location: ") | |
rm /tmp/headers.txt | |
location_header=$(sed 's|location: /||g' <<< $location_header) | |
gb_link="https://ghostbin.com/$location_header" | |
echo $gb_link | pbcopy | |
echo "Ghostbin paste created at: $gb_link" | |
echo "Link has been copied to your clipboard." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment