Linux – In Firefox, is there a shortcut to paste the content of the X buffer directly into the search box

firefoxlinuxsearchxorg

In particular when programming, it's handy to post error messages in Firefox' search box, to see what Google has to say on the matter 🙂 On linux and particularly X11, it's even more handy since you only have to select some text to put in the X buffer, to later paste it with the middle button.

Unfortunately, before pasting in the search box, you need to clear it. So basically I have to Ctrl+K Del middle click to paste my text in the search box. Not very handy anymore. Is there a better way?

Best Answer

The problem is subtle. You want a way to clear the contents of a text field without selecting the contents first, because selecting them will clobber your selection buffer's contents. In my opinion, this is a design flaw in whatever UI toolkits are used on Linux. Only manually selected text should be copied to the X primary selection, not text that is selected incidentally as a result of a non-text-selecting operation (e.g. clicking in a text field). But anyway, how about a couple of workarounds?

If you don't mind adding extra toolbar buttons, you can try the pastego extension: But I'm not sure it works with the X selection.

Another option is to install one of the many extensions that add clear buttons to the location/search bars, such as Clear Fields, DiggiDig, ClearURLButton, or xclear. Then, you just hit the clear button, and the text field is empty, ready for you to middle-click your own text into it.

Lastly, you can try clickngo, which does more or less exactly what you want, and seems to work in FF 3.5, despite the lack of a recent version bump.

Edit: I just remembered a command-line solution to this problem: surfraw. Here's the beginning of the package description:

Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell.

Basically, it lets to do google (and other) searches from the command line.

Related Question