Skip to content

Instantly share code, notes, and snippets.

@rtomayko
Created May 17, 2010 23:31
Show Gist options
  • Select an option

  • Save rtomayko/404378 to your computer and use it in GitHub Desktop.

Select an option

Save rtomayko/404378 to your computer and use it in GitHub Desktop.
bacon(1)
#!/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