• Home
  • Docs
  • About
  • Resume
  • Services
    • Testimonials
  • Contact
Humbug
Bah! Humbug!
Home 2010 Highlight and Search – Google Search from Any Ubuntu Linux Application

Highlight and Search – Google Search from Any Ubuntu Linux Application

  • Leave a comment
  • Tweet
Pratik Sinha | July 24, 2010

Some time ago, I wrote a post to show how to modify terminator to enable easy google searching. However I have trumped myself and have an even better solution now. Google Search from any application. Modus Operandi is: Highlight Text => Press Key Combination => Script picks up the query from the clipboard => Formats the query and opens the URL in your defualt browser.

Lets start with the script. Copy-Paste the below code into a file (Lets name it google_search).

#!/bin/bash
QUERY=`xclip -o | tr ' ' '+'`  #sanitize the query, change spaces to the plus sign
QUERY='"'$QUERY'"'    #put quotes around the query, exact search

if [ -x ~/bin/open_browser.sh ]; then
  open_browser.sh http://www.google.com/webhp?hl=en#hl=en\&q=$QUERY
else
  x-www-browser http://www.google.com/webhp?hl=en#hl=en\&q=$QUERY
fi

Copy the file to the bin directory under your home directory. Make the script executable.

cp google_search ~/bin
chmod +x ~/bin/google_search

Now lets take care of a few dependencies.

Install xclip. This utility is used to interact with the clipboard.

sudo aptitude install xclip

Update x-www-browser. See this tutorial for more instructions.

sudo update-alternatives --config x-www-browser

Now lets create a keyboard shortcut for the script we saved earlier.

Tutorial for KDE Users
Tutorial for Gnome Users

Thats it. Now you can highlight any text and press the keyboard shortcut you created in the last step and a google search for the selected phrase will open up in your default browser.

This script also supports the open_browser.sh script. Look here for more info.
When you press the keyboard combination, the browser may or may not become the active window. That depends on the focus model. However if you check your browser, the google search should be open in a new tab

Posted in Tips-N-Tricks | Tagged google search, Ubuntu | Leave a response

  • Tweet
Logging In...

Profile cancel

Sign in with Twitter Sign in with Facebook
or

Not published

 

« Previous Next »

Search

Recommend on Google
  • RSS
Follow @free_thinker

Get the latest posts delivered straight to your inbox.

Categories

  • Bookmarks
  • Code-Snippets
  • Guides
  • Info
  • Software
  • Testimonials
  • Tips-N-Tricks
  • Updates

Recently Popular

  • Make English the Default Language for Google Chrome Search
  • Parse Simple XML Files using Bash – Extract Name Value Pairs and Attributes
  • Kill/Quit and Restart Plasma on KDE
  • Bash Tricks: Split / Cut a String with Multi Character Delimiters
  • Enable SPDY in Firefox 11 on Ubuntu 12.04 beta
  • Utility to Send Commands or Data to Other Terminals (tty/pts)
  • A Sample Loop in XSL, Alternative for While, For Loops
  • Bash Tricks: Create variables dynamically using some eval magic
  • Kickstrap – CSS Framework: Enhancements for Bootstrap
  • WordPress Plugin: Cleaner WordPress Editor – Trying To Make WordPress Editing a Pleasure

Latest Tweets

  • 2 unexploded bombs found under Ho Chi Minh City house - Approximately 800,000 tons of bombs and mines still present humbug.in/z/9i #fb 4 weeks ago
  • 3 Vietnamese bloggers charged over their writing | Fox News humbug.in/z/9g #fb 1 month ago
  • Implement strong WiFi encryption the easy way with hostapd - Using WPA2-Personal with individual keys for each user humbug.in/z/9e 1 month ago
  • Soon, wonder vaccine that will kill 90% of cancers - Health - DNA humbug.in/z/9d 1 month ago
  • PHP like str_replace function in C: This post is part of a series of posts where I want to document a bunch of C f... humbug.in/z/9c 1 month ago

Services Offered

  • Embedded Linux Systems and Services
  • Gateway Routers (Frontend and Backend)
  • Free and Open Source Software Solutions
  • Network Monitoring Solutions
  • Device Driver Development


Mobile and Web Analytics

Recent Comments

  • Haakon Dahl commented on Make English the Default Language for Google Chrome Search
    (1 weeks ago)
  • pawan commented on Wordpress Error: The plugin generated 1 characters of unexpected output during activation
    (1 weeks ago)
  • simon commented on Detect Mobile Browser using Server Side Includes (SSI)
    (2 weeks ago)
  • hakatagroup commented on Twitter Weekly Updates between 2012-04-19 and 2012-04-25
    (3 weeks ago)

Tags

Address bar android awk bash C css custom post type debug Default Browser DNS dreamhost English Facebook firefox Google iphone JavaScript jquery KDE keyboard shortcuts Kubuntu Launchpad Linux Mozilla Firefox p2 page template pdf php plugin PPA python ruby ruby-on-rails Ruby1.9.2 Search Results SNMP theme tweets Twitter Ubuntu United States update-alternatives Vietnam wordpress xsl

Copyright © 2012 Humbug.

Powered by WordPress and Hybrid.