Skip to content

Instantly share code, notes, and snippets.

@Shadey
Last active August 29, 2015 14:26
Show Gist options
  • Save Shadey/39c2a27c405cfc2d2bcd to your computer and use it in GitHub Desktop.
Save Shadey/39c2a27c405cfc2d2bcd to your computer and use it in GitHub Desktop.
#!/usr/bin/sh
#requires imagemagick or scrot and curl xclip. Libnotify and a notification daemon should be nice
if [ -z $(command -v curl) ]; then echo "Please install curl"; exit;fi
if [ -z $(command -v scrot) ] && [ -z $(command -v import) ];then echo "Please install scrot or imagemagick";exit;fi
if [ -z $(command -v xclip) ]; then echo "Please install xclip to"; exit;fi;
tempfile="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1).png"
if [ ! -z $(command -v import) ]; then import $tempfile ; else scrot -s $tempfile; fi
res=$(curl -s "https://jii.moe/api/v1/upload" -F "file=@$tempfile")
url=$(python -c "import json;print(json.loads('$res')['url'])")
echo $url | xclip -selection clipboard
if [ ! -z $(command -v notify-send) ]; then notify-send "$url is in your clipboard"; else echo $url;fi;
rm $tempfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment