Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 "$(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 "$(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?

share|improve this question
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 – cipricus Nov 27 '12 at 10:39
up vote 3 down vote accepted

I will try to explain it...
the command sh -c 'firefox "$(xclip -o)"' will open firefox in 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 ""
  3. Open the file with gedit and put these lines: enter image description here
  4. Save the file in your home eg: /home/user/
  5. Then change the permissions to make the script executable in the terminal type: chmod 764 /home/user/
  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/ enter image description here
  9. Then give a keyboard shorcut to the 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 ~/</command>
share|improve this answer
thnx. you have answered my other question ( on how to search google from open is pretty clear that user55822 didn't mean that Artha can search the web, but just that the mouse selection can be searched by keybinding anywhere on the web in the way one usually uses mouse selection when searching Artha – cipricus Nov 27 '12 at 11:27
Thanks is more complete! – Roman Raguet Nov 27 '12 at 11:32
@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 '12 at 22:41
@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 "$(xclip -o)"' to open text in bing translator and to invoke that by shortkey no matter the ff search settings? – cipricus Dec 15 '12 at 23:04
sh -c 'firefox "$(xclip -o)"', if you want to translate I would recommend Google Translate, just change the line to 'sh -c 'firefox "$(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 – Roman Raguet Dec 16 '12 at 15:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.