Skip to content

Instantly share code, notes, and snippets.

@PsychoTea

PsychoTea/ghost.sh

Created Jul 19, 2018
Embed
What would you like to do?
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."
@haykam821

This comment has been minimized.

Copy link

@haykam821 haykam821 commented Jul 19, 2018

Thanks PsychoTea, very cool.

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.