Skip to content

Instantly share code, notes, and snippets.

@passalini
Last active August 29, 2015 14:04
Show Gist options
  • Save passalini/4a474e036f2f1a7de96f to your computer and use it in GitHub Desktop.
Save passalini/4a474e036f2f1a7de96f to your computer and use it in GitHub Desktop.
Upload files to upl.io through command line
# 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
@passalini
Copy link
Author

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