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.
xclip. This utility is used to interact with the clipboard.
sudo aptitude install xclip
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.
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.