Last active
August 29, 2015 14:26
-
-
Save Shadey/39c2a27c405cfc2d2bcd to your computer and use it in GitHub Desktop.
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
#!/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