Created
February 4, 2017 23:27
-
-
Save haze/516b05c3c7fb7766fab0241d678dea7e to your computer and use it in GitHub Desktop.
ill.sh os x upload script
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
#1/bin/sh | |
# written by haze (feb 4, 2017) | |
FILE=$1 | |
ILL_FOLDER=$HOME/.ill | |
KEY_FILE=$ILL_FOLDER/upload.key | |
if [ ! -f $KEY_FILE ]; then | |
echo "ill.fi upload key not found. creating file (~/.ill/upload.key), please pbpaste key into file." | |
if [ ! -d $ILL_FOLDER ]; then | |
mkdir $ILL_FOLDER | |
fi | |
touch $KEY_FILE | |
else | |
if [ -z "$1" ]; then | |
screencapture -i /tmp/ill-screenshot.png | |
FILE=/tmp/ill-screenshot.png | |
fi | |
DATA="$(curl --silent -F key=$(cat $HOME/.ill/upload.key) -F file=@$FILE https://ill.fi/api/upload)" | |
FILENAME=$(echo $DATA | jq -r '.filename') | |
ERROR_BOOL=$(echo $DATA | jq -r '.error') | |
ERROR=$(echo $DATA | jq -r '.message') | |
if [ "$ERROR_BOOL" == "false" ]; then | |
echo "https://ill.fi/$FILENAME" | pbcopy | |
else | |
echo $ERROR | pbcopy | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment