emacsewwqutebrowser

Is it possible to start eww with an url via script from shell?


Sometimes I read an article in my browser (qutebrowser) and think, oh "that article would be nice to work on in emacs". I can call scripts from the browser, and hand them the visited URL.

Is it possible to call emacs (or even better emacsclient, as I always have a server running) so, that it opens the given URL in eww?

I found that I can start emacs with a function to call, but not how to hand this function a parameter from outside. For emacsclient I didn' find even that possibility


Solution

  • You can eval arbitrary lisp with the --eval option of emacsclient. So you should be able to do something like this from the shell (season appropriately to call it from the browser):

        URL="https://google.com"
        emacsclient --eval "(eww \"$URL\")"
    

    The outer double quotes allow the shell to expand the URL variable. The escaped inner double quotes make the value of the URL variable into a string, which is what the eww function expects.