Posts Tagged ‘cli’

A pastebin with almost no user interface

I've always favoured pastebins that let you bin a paste and nothing more - p.defau.lt and sprunge.us spring to mind. I've made a Perl almost-clone of sprunge.us:

http://p.hashbang.ca now runs WWW::Hashbang::Pastebin, a simple pastebin written with Dancer and DBIx::Class that does nothing but store your text and show it back to you. The only feature beyond that is if you append a +, you'll get line numbering (no syntax highlighting). You can use an anchor to jump to any line (click the line number), and the number for that line will be highlighted.

To interact with the pastebin, just POST with paste content in p and get the URL back in the X-Pastebin-URL HTTP header (and in the body, so curl-ing will Just Work):

curl -F 'p=<-' http://p.hashbang.ca < /var/log/syslog
http://p.hashbang.ca/U

Or, use the Perl client, which provides a command-line tool to do the same thing (and also fetch paste content, given an ID).

CLI Perl syntax highlighter

Last night, someone posed a problem in #perl-help. They wanted to have syntax highlighting in their shell for Perl code. I immediately suggested that they use Pygments - I knew about it because I'd used it before, and I had experimented with the command line tool. But I was surprised there wasn't already a Perl solution.
(more…)