Anything can go here, in any language... except my native language Sinhala. Be cool... anybody is warmly welcomed! :)

Showing posts with label google. Show all posts
Showing posts with label google. Show all posts

Invoke Google's Web Search from Bash

Nice ideas come in handy way :) ; invoke Google's web search from your Linux desktop shell! :-O

Here's a small shell script that I wrote couple of minutes ago. Copy-paste it into a new file, save it inside /usr/bin as google. This works in GUI mode with firefox very well, but it doesn't work with lynx. I still could not find any reason,.. may be somebody can come up with an idea.

if [ $# -ne 0 ]
then
  query="http://www.google.lk/#hl=en&q="
  for i in $@
  do
    query=$query$i+
  done
  firefox $query &
else
  echo "Usage: google <your search query>."
fi


Then chmod +x /usr/bin/google as root to make it executable.

Now, enter the following as a command and see: B-)

$ google shaakunthala

Or,

Just press Alt+F2, type google shaakunthala and press Enter.


You can use whatever as your keyword. But, have to follow usual bash (shell) syntax.

For example,
If your query is sameera shaakunthala, your command should be,
$ google sameera shaakunthala

If your query is shaakunthala's portal, your command should be,
$ google shaakunthala\'s portal

If your query is "shaakunthala's portal", your command should be,
$ google "\"shaakunthala\'s portal\""

... and so on.

And use your creativity and combine this with some google search hacks that you know. It can be a powerful web search command from your desktop! :-O

Bye! Ciao! Sweet dreams! :P



*** Update ***

I re-wrote the script for lynx. The problem arises with the hash (#)sign in the URL. So I removed it. The whole thing is more convenient in the command line, than in the GUI mode.

if [ $# -ne 0 ]
then
  query="http://www.google.lk/search?hl=en&q="
  for i in $@
  do
    query=$query$i+
  done
  lynx -accept_all_cookies $query
else
  echo "Usage: google <your search query>."
fi

Here's the code explanation (how it works):
When you execute the script with some arguments, it will concatenate all arguments with plus sign (+) in between. This is necessary to parse the input as web browser URL format. Then it will concatenate it to the Google search URL string to pass it to the server script at Google.

And finally pass the whole thing as an argument to your web browser.

if - then - else - fi : Decision making
$# : Total number of arguements passed to the shell
-ne : not equals
for - do - done : Looping
$@ : all the arguments (except the command itself) passed to the shell

Ciao! :)

New Google Toolbar - makes it look alike Chrome

I updated my Google Toolbar few minutes ago. Yeah it's really amazing... Google has made Firefox look alike Chrome with the new version of Google Toolbar. The new version (version 5) has not yet released as stable but available as beta [get it right here].



What does look alike Chrome? Actually it is the New Tab Page. Install the latest beta build of Google Toolbar and open a new tab.



It looks like Google is going to integrate some of Chrome's features into Firefox. But why? This may keep Firefox users attached to Firefox forever, and may not tend to migrate to Chrome. What I feel is Google's ultimate target is not to market Chrome, but to market their profitable main products which are the Google search engine, Gmail and etc. Chrome is also made for achieving that ultimate goal of promoting their profitable products.

This new look ain't gonna be a good news for people who visit bad sites when the parents are out, is it? Anyway, I love this new style. :)

---
Earlier days, I wrote 'Google Chrome Sucks!'. But now slowly I'm becoming a Chrome lover.. You know.. things change.. :)

Followers

Subscription Options

 Subscribe in a reader

or

Enter your email address:

and
to inscrease

and make me happy. :)

Other Blogs by the Author

The Author

www.flickr.com
ශාකුන්තල | Shaakunthala's items Go to ශාකුන්තල | Shaakunthala's photostream
free counters
TopOfBlogs
Related Posts with Thumbnails