Skip to content

Instantly share code, notes, and snippets.

@rentalcustard
Created April 11, 2011 10:30
Show Gist options
  • Save rentalcustard/913334 to your computer and use it in GitHub Desktop.
Save rentalcustard/913334 to your computer and use it in GitHub Desktop.
Command-line wikipedia using DNS

This uses the awesome Wikipedia over dns hack to bring quick wikipedia lookups to your shell.

#Usage

Ξ ~ → qiki bacon
Bacon is a cut of meat taken from the sides, belly, or back of a pig, then cured, smoked,
or both. Meat from other animals, such as beef, lamb, chicken, goat, or turkey, may also 
be cut, cured, or otherwise prepared to resemble bacon. Bacon may be eaten f" "ried, baked,
or grilled, or used as a minor ingredient to flavor dishes. Bacon is also used for barding
and larding roasts... http://a.vu/w:Bacon

Ξ ~ → wiki bacon
#opens the wikipedia page for bacon
qiki() {
local query=$(echo $* | tr " " "_")
dig +short txt $query.wp.dg.cx | sed -e 's/^ *//' -e 's/^"//g' -e 's/"$//g'
}
wiki() {
open $(qiki $* | awk '{print $NF}')
}
@rentalcustard
Copy link
Author

Seems there's a bug with the wikipedia over dns service putting quotes in spaces into the txt record (see 'f" "ried' above).

@rentalcustard
Copy link
Author

That bug (or a related one) also causes some links to full articles to be garbled (e.g. 'qiki Sysadmin')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment