macosshellbrowser

Possible to pipe stdout directly to web browser?


I have some python utilities that generate HTML output. Instead of saving to a temporary file, and opening that in a web browser, I would like to be able to just redirect the output to the browser to preview it. For example, something like:

myscript.py | open /Applications/Safari.app

Is there any way to do such a thing? I am on OS X.


Solution

  • curl https://www.google.com | bcat
    

    If you can have ruby on your system you may install bcat:

    gem install bcat
    

    Make sure you have the gem binary folder in your path, e.g.:

    /home/{YOUR_USER_NAME}/.local/share/gem/ruby/{VERSION}/bin
    

    in my case that would be:

    /home/philipp/.local/share/gem/ruby/3.0.0/bin
    

    Then you'll have bcat command at your disposal in which you can pipe in html and which will then open your browser as shown above.