Last active
August 29, 2015 14:04
-
-
Save passalini/4a474e036f2f1a7de96f to your computer and use it in GitHub Desktop.
Upload files to upl.io through command line
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
# This command receives a file as param, upload it to upl.io and copy the url to the clipboard | |
# | |
# install: copy this code to your .bashrc or .zshrc | |
# dependencies: curl and xclip | |
# example: $ upload ~/Images/image.png | |
upload_file() { | |
echo 'Uploading...' | |
url=`curl http://upl.io -F file=@$1 -s -f` | |
curl_response=$? | |
echo -n $url | xclip -selection c | |
echo $url | |
if [ "$curl_response" = '0' ] && [ "$2" = '-d' ]; then | |
rm $1 | |
fi | |
} | |
alias upload=upload_file |
I just did it! =D
if you are in OSX change line 12 to echo -n $url | pbcopy
. I will update it to fit in OSX and Linux someday
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will be nice if you document it. What it does? How to use? Install?