Geekosopher

Yet Another Blog by Nitesh Mistry

Entries tagged "kde"

Paste in to KDE Pastebin using Pastebinit
11th January 2011

First off, Wish you all a Very Happy New Year (that is the heights of laziness, you think?).

We all love chatting and collaborating on irc and pastebins are very usefull for sharing more than 3-5 lines of text as otherwise most channels consider it as flooding.

Almost all major projects including Debian and Ubuntu amongst others have their own pastebin utility. The latest to launch one was KDE.

There are also pastebin clients to help you send the files to the pastebins right from the CLI without needing you to launch the web browser, open the pastebin website, upload the file / copy-paste the contents in to the text box and then finally grab the url of your paste. One of such pastebin clients is Pastebinit.

Pastebinit is a very simple to use program written in Python. The irssi fans will appreciate the fact that they don't even need to leave the console. Simply give it the location of your file or make it read from stdin and specify the pastebin you want to use. It uploads the content of the file (or whatever was passed on to it) to the specified pastebin and gives you the url of the paste as the output. Now that's cool stuff! Isn't it?

How to get it? The tar ball is here. If you are Debian or Ubuntu user, simply give the following in the terminal:

sudo apt-get update; sudo apt-get install pastebinit


"Whats new? I am already a pastebinit fan!" - you say. Alright, so here is the 'new' part - How to use pastebinit to post to the KDE's newly launched pastebin?

As of now, pastebinit is not configured to post to paste.kde.org. So what? Just add the following text in a file and save it as paste.kde.org.conf

[pastebin]
basename = paste.kde.org
regexp = "http://paste.kde.org"

[format]
user = paste_user
format = paste_lang
content = paste_data
password = paste_password
expire = paste_expire
private = paste_private
api = api_submit
mode = mode
regexp = regexp

[defaults]
private = 0
format = "text"
expire = 86400
api = 1
mode = xml
regexp = "<id>(.*)</id>"

Now save this file[1] in /etc/pastebin.d/ directory (which is automatically created when installing pastebinit).

That is it and you are good to go. Test it - give the following command:
pastebinit -i <location of the file to share> -b http://paste.kde.org
and most probably it will print the url of the paste and return the prompt.

If you want to use the KDE pastebin by default, add the following line to your .bashrc or (as the case may be, .bash_aliases) file:

alias pastebinit='pastebinit -b http://paste.kde.org'

Now you do not need to give the -b http://paste.kde.org argument each time to paste to the KDE's pastebin.

Note - The above patch is already committed upstream. So the next time it is packaged, it will work with KDE pastebin service by default. But with all the doomsday predictions making rounds, why wait till then? :)

1 - Thanks to St├ęphane Graber for pointing out the missing 'regexp' lines.

Email comments to Nitesh Mistry   Tags: geekosophy, greetings, howto, kde, linux, pastebin.