Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opening standard stream in google-chrome

I have a program that creates a html file as standard output. To view it in vim I just need to:

$ foo2html foo | vim -

vim will be launched with stdin read-in for viewing. Once I close vim the command will return.

Is there some combination of command-line switches that will make google-chrome do this?

like image 797
Andrew Tomazos Avatar asked Jan 28 '12 13:01

Andrew Tomazos


People also ask

How do I change the app that opens in Chrome?

Highlight the icon for a file with the extension you want to re-associate and press "Command-I" on your keyboard. In the "Get Info" window, expand the "Open With" section and select a new application to use as the default for launching these types of files.

Can I open a video in Chrome?

Watch a video across Chrome tabsYou can play a video from one tab in a smaller window on top of other tabs you browse. In a tab, play a video.


1 Answers

Just use data URIs:

# google-chrome
echo '<h1>hello</h1>' | google-chrome "data:text/html;base64,$(base64 -w 0)"

# firefox (it will not automatic open since version 89, you must go to url and press enter)
echo '<h1>hello</h1>' | firefox "data:text/html;base64,$(base64 -w 0)"

# chromium
echo '<h1>hello</h1>' | chromium "data:text/html;base64,$(base64 -w 0)"

# opera
echo '<h1>hello</h1>' | opera "data:text/html;base64,$(base64 -w 0)"

# Default browser (in debian systems)
echo '<h1>hello</h1>' | x-www-browser "data:text/html;base64,$(base64 -w 0)"

The command base64 is available from coreutils on debian like systems

sudo apt-get install coreutils

If you not have coreutils installed or you cannot install new packages, you could use the python module base64 (virtually any distro has python)

echo '<h1>hello</h1>' | google-chrome "data:text/html;base64,$(python -mbase64)"
like image 179
iuridiniz Avatar answered Sep 22 '22 05:09

iuridiniz