Is there a tool which can pass the content of the clipboard as parameter to some application?

For example I would use it like this:

(1) In a text editor or whatever, for example I could highlight and copy the IP number "", to the clipboard.

(2) Activate the tool I'm looking for; it should launch the URL http://www.geoiptool.com/en/?IP= in a browser.

Essentially, it would be something reminding of the chrome extension "send-me-this" https://chrome.google.com/webstore/detail/send-me-this/kgadhdbaebgblhbgojbegdjhmemapfgc , but it should be available everywhere, I mean not just when I'm in a browser.

I am on Ubuntu 10.04.



An easy way o do this would be to use xclip:

  1. Install xclip

    sudo apt-get install xclip
  2. Add this line to your $HOME/.bashrc file:

    alias geoip='xdg-open http://www.geoiptool.com/en/?IP=$(xclip -o)'
  3. Select the IP, open a new terminal and run



That should open your default browser on the geoip page for that IP. This assumes you have xdg-open installed, if you don't, either install it (sudo apt-get install xdg-utils), or change xdg-open to chrome or firefox or whatever browser you use. Also, if you use this when the clipboard's content is not an IP it will launch he browser but won't be able to load the page.

You should also be aware that there is more than one clipboard available, so the above will work if you have selected an IP, not if you have used CtrlC. To use it with the latter, you should instead do

alias geoip='xdg-open http://www.geoiptool.com/en/?IP=$(xclip -selection "clipboard" -o)'

For more information, see man xclip.

If you want to run it without a terminal, make a shortcut for the command

xdg-open http://www.geoiptool.com/en/?IP=$(xclip -o)'
  • Very useful answer, thanks! It works fine with the alias. However, I have one problem which I managed to work around: I get an error if I put the code into the command field in a custom shortcut or launcher, for some reason the URL seems to be truncated to 'geoiptool.com/en/?IP=$(xclip' . If I place the code into a bash script and write the path to the script in the command field, then it works perfectly. – Jakob Vinther Sep 19 '13 at 12:30
  • The was a typo in my comment. The URL is actually truncated to http://www.geoiptool.com/en/?IP=$(xclip – Jakob Vinther Sep 19 '13 at 12:40
  • @JakobVinther umm, still not sure I understand. Does it work for you or not? If you want to make a shortcut, you might need to quote the entire command. Please remember to accept this answer if it solved your problem so the question can be marked as answered. – terdon Sep 19 '13 at 13:36
  • It is all fine, the only strange thing is that it doesn't work with the code directly in the shortcut. I have tried quoting the whole thing with " as well as ', but none of them worked. The last part -o) is lost somehow. It doesn't matter, because I'm very happy with the solution you gave, and I have accepted it of course. – Jakob Vinther Sep 19 '13 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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