Skip to content

Instantly share code, notes, and snippets.

@PsychoTea
Created July 19, 2018 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PsychoTea/1d2ff0db968f3b700f306fea76cb63eb to your computer and use it in GitHub Desktop.
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
#!/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