Friday, March 19, 2010

A Wikipedia query in your terminal

Open ~/.bashrc with your favourite editor.
gedit ~/.bashrc

Place the following to the end:
#wikipedia
function wiki () {

COLUMNS=`tput cols`

dig +short txt "`echo $@`".wp.dg.cx | sed -e 's/" "//g' -e 's/^"//g' -e 's/"$//g' -e 's/ http:/\n\nhttp:/' | fmt -w $COLUMNS

}

Reset your bash terminal: $bash

To invoke type wiki <subject-of-your-query>. It will return some interesting and useful information.

No comments:

Post a Comment