Created
May 17, 2010 23:31
-
-
Save rtomayko/404378 to your computer and use it in GitHub Desktop.
bacon(1)
This file contains hidden or 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
| #!/bin/sh | |
| # Usage: bacon <file> | |
| # Upload <file> to baconfile.com and copy URL to pasteboard. | |
| # | |
| # You baconfile.com credentials must exist in ~/.netrc, like this: | |
| # | |
| # machine baconfile.com | |
| # login garfield | |
| # password ironman04 | |
| # | |
| set -e | |
| file="$1" | |
| # TODO grab this from ~/.netrc | |
| username=rtomayko | |
| # upload to baconfile and store json result | |
| info=$(curl -# --netrc -F file=@${file} http://baconfile.com/${username}.json) | |
| # pull out URLs | |
| permalink=$(echo "$info" | sed 's/.*"permalink": "\([^"]*\)".*/\1/') | |
| fileurl=$(echo "$info" | sed 's/.*"file_url": "\([^"]*\)".*/\1/') | |
| # put it on the pasteboard | |
| printf "$permalink" | pbcopy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment