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 pastebin.ca, 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 pastebin.ca URL of the input file

If FILE is omitted content is read from standard input
OPTIONS:
        -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.


Posted

in

,

by

Tags:

Comments

16 responses to “The wonders of pastebin”

  1. Dennis Kaarsemaker Avatar

    For pastebin.com-like sites I have created a script just like it (it’s even python) a few months ago – http://www.ubuntulinux.nl/files/pastebin

  2. Ikke Avatar

    Cool stuff!

    Ikke

  3. pvanhoof Avatar

    Using it! Thanks a log

  4. pvanhoof Avatar

    Err, lot. Not log 🙂

  5. MacSlow Avatar

    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…

    MacSlow

  6. Wed

    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.  Avatar
    Anonymous

    nice

  8. jake Avatar

    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 pastebin.ca 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 Avatar

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

    to

    # Default Values
    […]
    expiry = “5 minutes”

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

  10. jake Avatar

    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 pastebin.ca. A neat script like this proves to be extremely useful sometimes. […]

  12. Marc Avatar
    Marc

    Nice, thank you

  13. Azzurra Avatar

    Buon luogo, congratulazioni, il mio amico!

  14. alex Avatar

    hi nice site.

  15. NightStrike Avatar

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