How to pipe from clipboard to firefox?

2

This might be a amateur question. But I have a problem with piping. I want to pipe my clipboard to firefox via the terminal. In my clipboard is a url like https://www.google.com. Than I want open firefox like

firefox https://www.google.com

Now I want to replace the google URL by something of my clipboard. I tried to pipe it like:

xclip -o -selection clipboard | firefox
xclip -o -selection clipboard > url ; firefox url
xclip -o -selection clipboard > url ; cat url | firefox /dev/fd/0

All 3 aren't working.

Any suggestions on how I could solve this?

ChrizZly

Posted 2017-08-25T14:21:33.267

Reputation: 23

Answers

3

Firefox only takes URLs as command line parameters, not as stdin, and these are distinct things. So the pipe is not broken, it's just the wrong tool.

You need one of the following:

  • "Command substitution" using the $(…) or `…` operators:

    firefox $(xclip -o -selection clipboard)
    
  • A program which does take input from stdin, and converts it to command-line arguments:

    xclip -o -selection clipboard | xargs firefox

user1686

Posted 2017-08-25T14:21:33.267

Reputation: 283 655