The wonders of pastebin

These last days, i’ ve been using pastebin intensively, for things like diffs reviews, code snippets to discuss, etc.

And i got sick of the web interface.

So i took a couple of hours to write this nice python script which allows to upload seamlessly any content to, and maybe it will be useful for other people than me, so i publish it here.

Very simple to use here is the usage():

$ pastebin [OPTIONS] [FILE]

Print the URL of the input file

If FILE is omitted content is read from standard input
        -h, --help                      Print this help notice.
        -r, --raw                       Retreive raw text URL (default=off).
        -d, --description       The description of the content (default=empty).
        -m, --message           Same as description
        -n, --name                      Your name (default=your unix username).
        -t, --type                      The type of the content (default="raw")

        Type can be one of:
        raw, asterisk, c, cpp, php, perl, java, vb, csharp,
        ruby, python, pascal, mirc, pli, xml, sql, scheme,
        ascript, ada, apache, nasm, asp, bash, css, delphi, html, js,
        lisp, lua, asm, objc, vbnet

        If type is not specified, an attempt to auto-detect type is made,
        based on file data/extension. Detection is more reliable when giving FILE
        argument than piping directly. This needs modules gnomevfs and gtksourceview

        If you have module gtk, the pastebin url will be placed in your clipboard,
        you can then paste it with ctrl-v as usual.

That means you can cat important-patch.diff|pastebin -m 'look!' then Ctrl-v in xchat or wherever the output URL.

16 Responses to “The wonders of pastebin”

  1. For sites I have created a script just like it (it’s even python) a few months ago –

  2. Ikke says:

    Cool stuff!


  3. pvanhoof says:

    Using it! Thanks a log

  4. pvanhoof says:

    Err, lot. Not log 🙂

  5. MacSlow says:

    Very nice! But the automatic inclusion in the clipboard of the generated pastebin-URL doesn’t work for me. Or do I misunderstand this here:

    “… you can cat important-patch.diff|pastebin -m ‘look!’ then Ctrl-v in xchat…”

    I still have to mark the outputted URL from the pastebin-script explicitly in order to get in in the clipboard.

    Thanks anyway for this nice python-gem!

    Best regards…


  6. rejon's blog says:


    I’ve noted a few links about an individual dev. on the gimp who is wreaking havoc for them. Talk about a crank!

    I’ve found the best way to deal with issues like this is offlist. However, if this kind of thing persists (which I haven’t had to deal…

  7. Anonymous says:


  8. jake says:

    Tha author wrote:
    maybe it will be useful for other people than me

    “Maybe” ??
    This is pure shell genious.
    At first it died on me, funky error message, probably did something illegal, but now it works like a charm.

    Now, the question is, would it be possible to use the setting over at that forces the paste to expire after X time? In the default state, i think the paste stays there forever and i think thats unnecessary.

  9. kikidonk says:

    It’s easily done, just modify the
    # Default Values
    expiry = “”


    # Default Values
    expiry = “5 minutes”

    or any other string found in the EXPIRATIONS array on top of the file

  10. jake says:

    kikidonk: thank you! fantastic!

  11. […] While browsing the archives of Raphael Slinckx’ blog, among other very interesting things, I came across a post about a Python script of his, which uploads a text file on the on-line pastebin A neat script like this proves to be extremely useful sometimes. […]

  12. Marc says:

    Nice, thank you

  13. Azzurra says:

    Buon luogo, congratulazioni, il mio amico!

  14. alex says:

    hi nice site.

  15. NightStrike says:

    Is there any way to make the expiration command-line driven?