How can I pipe HTML content to Safari via the command line? I have a situation in which I'm getting HTML content via a pipe.  I'd like to display it in a browser window.  But the obvious step, 

somethingThatProducesHTMLonStdout | open -f -a "Safari"


does not work: Safari displays the content, but as plain text; it does not render the HTML. I know for a fact that my HTML content is valid HTML content.  In fact, it is easy to demonstrate this problem with a trivial test case:

echo "&lt;html&gt;&lt;body&gt;foo&lt;/body&gt;&lt;/html&gt;" | open -f -a "Safari"


does the same thing – displays plain text, not rendered content.  I'm at a loss as to why Safari insists on doing this.  What is the secret to making it render the HTML?

Note: I know I can make this work by saving the content to a temporary file and then opening the temporary file.  I want to make it work without using a temporary file, if it is possible.
You can use something like

echo '&lt;html&gt;&lt;body&gt;&lt;h2&gt;Hi, there!&lt;/h2&gt;foo&lt;/body&gt;&lt;/html&gt;' &gt; /tmp/x.html &amp;&amp; open -a "Safari" /tmp/x.html


I entered some HTML that contains an exclamation mark to show that you need to use single quotes for the shell, otherwise it will interpret this as a history recall. Yes, longer and you need a file name, but you can use your somethingThatProducesHTMLonStdout tool from your question.