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! :)
Comments (5)
October 27, 2009 at 11:48 PM
එළ නෙ ටර්මිනල් එකෙන් ගූගල් යන එකත් පට්ටයි නෙ .... :)
October 27, 2009 at 11:53 PM
ඔව්.. GUI එකක් නැති වෙලාවට lynx පාවිච්චි කරන එක ඊටත් ඉක්මන්. :)
November 9, 2009 at 10:50 AM
එල මැක්සා වැඩක්නෙ!GUI ත් තාම හරියට බැරි අපිට lynx ගැන මොන කතාද?
November 22, 2009 at 8:08 PM
තනිකරම textmode ලොග් වෙලා ifup eth0 දීල ලෑන් එක අප් කරගෙන lynx වලින් යන්න උන වෙලාවලුත් තිබුණා. (root ෆුල් උන වෙලාවක වගේ මතක) මේක නම් මැක්සා. දාගන්න ඕන
August 17, 2012 at 10:58 PM
thanks !
Post a Comment