It seems possible (as I learned from a comment to this question made by user55822) to use a command in order to search a term on the web by using "keybinding" the way Aretha is used.

What the aforementioned user says is that

"you could search mouse selection anywhere by using an app like Artha, or by keybinding sh -c 'firefox "http://translate.google.com/#en/fr/$(xclip -o)"' (example given translate english into french)"

A lot of things are obscure for me here. I could use Artha or keybinding (as alternative), or both? How to do that in each case?


"The command I gave you will open google translate in Firefox with your mouse selection (text highlighted) as a query. Use sh -c 'firefox "https://www.google.com/search?q=$(xclip -o)"' if you want regular Google over Google translate. And obviously, that would work everywhere"

I do not know what to do with that formula. What should I do exactly? How to use it? In what application?

  • the answer to this question is of course true not only for text editors, but for selected text in any text page including web browsers and so on
    – user47206
    Nov 27, 2012 at 10:39

2 Answers 2


I will try to explain it...
the command sh -c 'firefox "https://www.google.com/search?q=$(xclip -o)"' will open firefox in www.google.com searching the words you have selected with your mouse.
To use it , you should install "xclip"

  1. Go to the terminal and type sudo apt-get install xclip
  2. Then you can create a script with the command, create a "new document" and named as "search-google.sh"
  3. Open the file with gedit and put these lines: enter image description here
  4. Save the file in your home eg: /home/user/search-google.sh
  5. Then change the permissions to make the script executable in the terminal type: chmod 764 /home/user/search-google.sh
  6. Then you can create a custom keyboard shortcut to execute the script.
  7. Go to System Settings > Keyboard > shortcuts > Custom Shorcuts enter image description here
  8. Add a new item and fill the fields Name:search-google and Command:sh/home/user/google-search.sh enter image description here
  9. Then give a keyboard shorcut to the script...click in "Disabled" and press the keys to the shortcut. eg: Ctrl+Alt+G enter image description here

  10. So, if you are in a web page or any document and you select or (text highlighted) a word or phrase... then press the keys for the shortcut eg: Ctrl+Alt+G and Firefox will open searching in google for the text you have highlighted o selected.

On the other hand I think the user55822 tried to say was the Artha
application works like this command.. the difference is by default if you have a text selected with Ctrl+Alt+W Artha will serch for that text but "offline" (As far as I know.)
But you can use both, if you need to search in Artha select the text and press the
shorcut keys Ctrl+Alt+W, but if you want to look in google "online" you can use the script with the shorcut Ctrl+Alt+G.

All the credit for the command is for user55822

Hope will be useful.

Edit: The above instructions on setting the shortcut are for Ubuntu (proper). To set the shortcut for that script (or for any script like that) in Xubuntu, see the answers to this question. To set the shortcut in Lubuntu (which does not have a GUI for that purpose):

Paste in Terminal:

sudo gedit ~/.config/openbox/lubuntu-rc.xml 

There are a lot of groups of lines that set the keybinds and look like so:

<keybind key="C-A-t">
      <action name="Execute">

To add a keybind for the google search script, insert this at the end of one of those groups:

<keybind key="C-A-g">
      <action name="Execute">
        <command>sh ~/search-google.sh</command>
  • 2
    @cipricus if you use firefox -search "$(xclip -o)", firefox will use your default search engine to search for the selected text, if you set your search engine to bing then that should work. Apart from that, yes, you'd have to set different search engines separately.
    – evilsoup
    Dec 15, 2012 at 22:41
  • 1
    @evilsoup: it seems that puting sh -c 'firefox -search "$(xclip -o)"' in the script searches the item in google no matter what i set as default search engine. but is it not possible to adapt sh -c 'firefox "https://www.google.com/search?q=$(xclip -o)"' to open text in bing translator and to invoke that by shortkey no matter the ff search settings?
    – user47206
    Dec 15, 2012 at 23:04
  • @cipricus if you want to search in Bing, just change the line to Dec 16, 2012 at 15:07
  • 2
    sh -c 'firefox "www.bing.com/search?q=$(xclip -o)"', if you want to translate I would recommend Google Translate, just change the line to 'sh -c 'firefox "http://translate.google.com.ar/#en/es/$(xclip -o)"' in this case from English (en) to Spanish (es). If you want to translate in Bing you can try with xdotool, sudo apt-get install xdotool and create the script Dec 16, 2012 at 15:23
  • has something changed with google translate? cannot seem to make that work lately
    – user47206
    Apr 24, 2015 at 12:08

To have a short and clear answer based on the main one:

sudo apt-get install xclip

Add the following commands (worked directly for me, no script needed), for Google search:

sh -c 'firefox "https://www.google.com/search?q=$(xclip -o)"'

For Google translate (example for French to English):

sh -c 'firefox "http://translate.google.com/#fr/en/$(xclip -o)"'

replacing the language and browser if needed.

For Google Translate to English from any (auto-detected) language:

sh -c 'firefox "http://translate.google.com/#auto&tl/en/$(xclip -o)"'

You must log in to answer this question.