SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-06-04 04:42:19

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,843
Website

quick wiki lookup in terminal

Another gem from commandlinefu.com, via this page. Add this line to your .bash_aliases:

wiki() { dig +short txt $1.wp.dg.cx; }

and type 'wiki keyword' to get a quick paragraph from wikipedia in your terminal. cool

(I had 'dig' already installed on #!9.04, I haven't checked for Statler.)

edit This version lets you input multiple-word phrases without having to put them in quotes:

wiki() { dig +short txt "$*".wp.dg.cx; }

Last edited by johnraff (2010-06-04 18:12:21)


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

Help fund CrunchBang, donate to the project!

#2 2010-06-04 06:18:10

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,057
Website

Re: quick wiki lookup in terminal

Nice tip, thank you for sharing. smile

Offline

#3 2010-06-04 10:55:52

benj1
Wiki Wizard
From: Yorkshire, England
Registered: 2009-09-05
Posts: 1,084

Re: quick wiki lookup in terminal

ah comandlinefu

i use a slightly improved version

function wiki() #check wikipedia
{ dig +short txt "${@}".wp.dg.cx | awk 'BEGIN{RS="\" \"";ORS=""} // {gsub("\"",""); sub("htt","\nhtt"); print}';}

gets rid of the quotes etc.

also theres:

function cmdfu() #get stuff from cammandline fu 
{ wget -O - "http://www.commandlinefu.com/commands/matching/$@/$(echo -n "$@" | openssl base64)/plaintext";}

- - - - - - - - Wiki Pages - - - - - - -
#! install guide           *autostart programs, modify the menu & keybindings
configuring Conky       *installing scripts

Offline

#4 2010-06-04 18:08:27

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,843
Website

Re: quick wiki lookup in terminal

benj1 wrote:

ah comandlinefu

Fun!

i use a slightly improved version

function wiki() #check wikipedia
{ dig +short txt "${@}".wp.dg.cx | awk 'BEGIN{RS="\" \"";ORS=""} // {gsub("\"",""); sub("htt","\nhtt"); print}';}

gets rid of the quotes etc.

added that stuff at the end to my personal version and it does take out the quotes. Couldn't see any other difference though.
btw, for multi-word query phrases I think that "${@}" could perhaps better be a "$*" in this case?

Another recent discovery, to translate from any language to English, or other target language, with the 2-letter language code:

translate(){ wget -qO- "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=%7C${2:-en}" | sed 's/.*{"translatedText":"\([^"]*\)".*/\1\n/'; }

eg 
translate 'chien noir' ja
returns
黒い犬
cool -not my own work, though...


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#5 2010-06-05 16:52:07

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,843
Website

Re: quick wiki lookup in terminal

benj1 wrote:
function cmdfu() #get stuff from cammandline fu 
{ wget -O - "http://www.commandlinefu.com/commands/matching/$@/$(echo -n "$@" | openssl base64)/plaintext";}

I had been using a version with curl instead of 'wget -O -' but it wouldn't take multi-word searches for some reason. Yours works though smile
Try

wget -qO - 

to get rid of wget's commentary.

Last edited by johnraff (2010-06-05 16:53:18)


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#6 2010-06-06 14:49:52

benj1
Wiki Wizard
From: Yorkshire, England
Registered: 2009-09-05
Posts: 1,084

Re: quick wiki lookup in terminal

johnraff wrote:

Try

wget -qO - 

to get rid of wget's commentary.

good tip.

I'm guessing i used "${@}" , so i could do 'wiki foo,bar' and get pages for foo and bar, it doesn't work so i probably just left it.


- - - - - - - - Wiki Pages - - - - - - -
#! install guide           *autostart programs, modify the menu & keybindings
configuring Conky       *installing scripts

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo