Initiating a Google Search by Selecting text and pressing a Hot Key

April 19th, 2012 By arlinton Categories: System Administration

My friend Meethune was looking for a feature to simplify his google searches, he wrote:

I was looking for a “select -> right click -> search google” feature for gnome-terminal. I didn’t find anything however I did find this little gem. Bind the following one liner to a keyboard shortcut in whatever window manager you use.

 sh -c 'xsel | tr " " "+" | xargs -I %s xdg-open ""'

Now I can select something in my terminal window and press “ctrl+shift+g” and a new tab opens in my browser with a query on Google of the selection.

I thought this was cool and wanted to share. I’ve currently use this on my Fedora desktop machines and can select text from any application (I’ve tested with gnome-terminal, xterm, firefox) and can initiate a search on google with a single key combination.

Here’s some info from the rpm package that allows this interaction to be successful. I hope this helps you implement or set this up on the operating system of your choosing:

$ rpm -qi xdg-utils-1.1.0-0.10.20111207.fc16.noarch
Name        : xdg-utils
Version     : 1.1.0
Release     : 0.10.20111207.fc16
Architecture: noarch
Install Date: Mon 13 Feb 2012 03:43:39 PM EST
Group       : System Environment/Base
Size        : 273423
License     : MIT
Signature   : RSA/SHA256, Fri 09 Dec 2011 08:07:36 AM EST, Key ID 067f00b6a82ba4b7
Source RPM  : xdg-utils-1.1.0-0.10.20111207.fc16.src.rpm
Build Date  : Wed 07 Dec 2011 01:45:56 PM EST
Build Host  :
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         :
Summary     : Basic desktop integration functions
Description :
The xdg-utils package is a set of simple scripts that provide basic
desktop integration functions for any Free Desktop, such as Linux.
They are intended to provide a set of defacto standards.
This means that:
*  Third party software developers can rely on these xdg-utils
   for all of their simple integration needs.
*  Developers of desktop environments can make sure that their
   environments are well supported
*  Distribution vendors can provide custom versions of these utilities
The following scripts are provided at this time:
* xdg-desktop-icon      Install icons to the desktop
* xdg-desktop-menu      Install desktop menu items
* xdg-email             Send mail using the user's preferred e-mail composer
* xdg-icon-resource     Install icon resources
* xdg-mime              Query information about file type handling and
                        install descriptions for new file types
* xdg-open              Open a file or URL in the user's preferred application
* xdg-screensaver       Control the screensaver
* xdg-settings          Get various settings from the desktop environment

One Response to “Initiating a Google Search by Selecting text and pressing a Hot Key”

  1. September 17th, 2014 at 23:50

    Nice post. I learn something new and challenging on blogs I stumbleupon every
    day. It’s always interesting to read articles from other writers and use something from other sites.

Leave a Comment