cat /dev/brain

Sprunge.us

The Context

I use sprunge.us on the rare occasion that I need to paste something for someone else to see. It's simple to use, written in python and open source. The chief example when you visit the website uses curl (and I love using the command line for as much as possible).

What annoyed me was that I often messed up the syntax because of how infrequently I used the site. So I would often run:

$ curl http://sprunge.us

<style> a { text-decoration: none } </style>
<pre>
sprunge(1)                          SPRUNGE
sprunge(1)

NAME
    sprunge: command line pastebin:

SYNOPSIS
    &lt;command&gt; | curl -F 'sprunge=&lt;-' http://sprunge.us

DESCRIPTION
    add <a href='http://pygments.org/docs/lexers/'>?&lt;lang&gt;</a> to
    resulting url for line numbers and syntax highlighting

EXAMPLES
    ~$ cat bin/ching | curl -F 'sprunge=&lt;-' http://sprunge.us
       http://sprunge.us/VZiY
    ~$ firefox http://sprunge.us/VZiY?py#n-7

SEE ALSO
    http://github.com/rupa/sprunge

</pre>

My problem was remembering the form syntax for curl, specifically, form-identifier<- where the <- was the crucial part. This allows you to do:

$ cat file.txt | curl -F 'sprunge<-' http://sprunge.us
$ curl -F 'sprunge<-' http://sprunge.us < file.txt
$ curl -F 'sprunge@file.txt' http://sprunge.us
$ echo 'file.txt' | curl -F 'sprunge@-' http://sprunge.us

all of which are equivalent. But frankly, I'm a bit too lazy to do all that typing, so I wrote myself a nice little python script to do the work for me. To make it easy to remember, I named it sprunge.py.

Sprunge.py

All this requires is requests which is released by Kenneth Reitz and contributed to by plenty. You can download it here or from PyPi using pip install sprunge.py.