I needed a simple pastebin, and I didn't feel like writing PHP or figuring out how to deploy Python web code, so I figured... well, I don't need a web service, right?
This script takes a file with content to paste and generates pretty HTML using Pygments, and then uploads it somewhere and spits out a URL.
It currently writes to a local file or uses scp to upload - depending on the
system it's running on - but you can (and should) change this by modifying the
upload()
function inside paste.py
. Runs on both Python 2.x and 3.x.
Created by Ninjifox, 22nd February 2014
Licensed under the Do What The Fuck You Want To Public License ;)
Syntax: python paste.py <language> <path-to-file>
Example command line: python paste.py python paste.py
Language is a standard Pygments short lexer name - the only exception is irc
,
which bypasses Pygments entirely and uses a custom log munger I wrote,
located inside irc_highlight.py
.
gencss.py
outputs CSS to stdout containing the styles used by Pygments's
highlighted output, and a bunch of other things. The generated HTML loads this
from res/style.css
by default.
Paste names generated by this script include a timestamp and 8 random
alphanumeric characters, for example: 140221.204843.krigifbd
A copy of the original paste data is also output into a file with the
same name in the raw
directory.