HowFlow


HowFlow — Search with your favorite shell straight from the commandline. Functions for Google, Wikipida, LEO, Netcraft, Debian, Wiktionary

Share it!   Posted by lied lied 8 months ago

Here are some functions to search on the commandline.

You have to put the functions into your ~/.zshrc to load it automatically within new shells.

Here we go: First we have setup the Browser you want to use. I store the Browser in $BROWSER I set the BROWSER automatically with this lines of code:


if [[ -z "$BROWSER" ]] ; then
    if [[ -n "$DISPLAY" ]] ; then
        #v# If X11 is running
        firefox && export BROWSER="opera" 
    else
        #v# If no X11 is running
        w3m && export BROWSER="w3m" 
    fi
fi
So if I have an Xserver running I have my favorite Browser opera else I use w3m. nice or ;) Take the searches you need and copy it to ~/.zshrc

# Search German  Wiktionary
dwicti()  { ${=BROWSER} http://de.wiktionary.org/wiki/${(C)1// /_} }

# Search English  Wiktionary
ewicti()  { ${=BROWSER} http://en.wiktionary.org/wiki/${(C)1// /_} }

# Search Google Groups
ggogle()  { ${=BROWSER} "http://groups.google.com/groups?q=$*" }

# Search Google
google()  { ${=BROWSER} "http://www.google.com/search?&num=100&q=$*" }

# Search Google Groups for MsgID
mggogle() { ${=BROWSER} "http://groups.google.com/groups?selm=$*" }

# Search Netcraft
netcraft(){ ${=BROWSER} "http://toolbar.netcraft.com/site_report?url=$1" }

# Use German Wikipedia's full text search
swiki()   { ${=BROWSER} http://de.wikipedia.org/wiki/Spezial:Search/${(C)1} }

# search \kbd{dict.leo.org}
oleo()    { ${=BROWSER} "http://dict.leo.org/?search=$*" }

# Search German   Wikipedia
wikide()  { ${=BROWSER} http://de.wikipedia.org/wiki/"${(C)*}" }

# Search English  Wikipedia
wikien()  { ${=BROWSER} http://en.wikipedia.org/wiki/"${(C)*}" }

# Search official Debian debs
wodeb()   { ${=BROWSER} "http://packages.debian.org/search?keywords=$1&searchon=contents&suite=${2:=unstable}&section=all" }
Usage:
functionname <searchpattern>
w3m or opera pops up with the results :)

This functions should also work on bash, try it and leave a comment if it works :) EDIT:click here for bash

For more tricks like this have a look at grml (www.grml.org)



Please log in or sign up and vote for this trick if it was helpful for you.
Don't forget to subscribe to our RSS Feed RSS/Atom feed to get the latest tricks.