4

For example, could I type something like

firefox open this is a search

where open is just passed to the vimperator command line?

drs
  • 5,453
George
  • 1,809
  • Not sure about vimperator/pentadactyl options but if you want to open browser and pass string to default search engine you can do that: $ firefox -search 'this is a search'. – anlar Oct 04 '14 at 09:02
  • 1
    I asked this Q in the #vimperator IRC on freenode, nobody has responded thus far but I'll keep checking. I've also asked your Q on the Vimperator github project pg: https://github.com/vimperator/vimperator-labs/issues/48 – slm Oct 04 '14 at 13:13

1 Answers1

4

Vimperator founder here:

Yes, it is possible. The complete syntax is here: https://github.com/vimperator/vimperator-labs/blob/master/common/locale/en-US/starting.xml or given in :help startup

So try that:

firefox -vimperator "+c 'javascript alert(\"from commandline\");'"

would show an prompt after starting firefox. For opening URLs or searching, you need a slight "hack" as there is a race condition and we need to add a slight delay like so:

firefox -vimperator "+c \
    'javascript liberator.sleep(1000) && liberator.open(\"this is a search\");'"

If it is really required to put that content into the command line and not executing it directly, you can try the normal command:

firefox -vimperator "+c 'normal \":open this is a search\"'"

In general, pay attention about the correct escaping of quotes. I recommend using the mixture of " ' and \" like in the above examples.

Simplifying things

You can use the following function to make this a single one-liner, like so:

$ function vimpopen () {
    firefox -vimperator "+c 'normal \":open $@\"'"
}
slm
  • 369,824
  • I'm still a command line/linux newbie. Is there something I could type into my bashrc to simplify this to a single command, like "vimpopen 'here is a search'"? – George Oct 04 '14 at 22:20
  • @George - see the example at the end, LMK if that works for you. – slm Oct 05 '14 at 18:07
  • Thanks for your respond(!), but it didn't work. I changed it to the following:

    function vimpopen() { firefox -vimperator "+c 'normal :open $@'"; }

    And it sort of worked. Firefox opens with what I type and I have to press enter. The terminal is also linked to the firefox window so that if I close out of the terminal, then firefox also closes -- which isn't desirable.

    – George Oct 11 '14 at 23:05