Skip to content

Instantly share code, notes, and snippets.

@haze
Created February 4, 2017 23:27
Show Gist options
  • Save haze/516b05c3c7fb7766fab0241d678dea7e to your computer and use it in GitHub Desktop.
Save haze/516b05c3c7fb7766fab0241d678dea7e to your computer and use it in GitHub Desktop.
ill.sh os x upload script
#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