簡體   English   中英

在google-chrome中打開標准流

[英]opening standard stream in google-chrome

我有一個程序可以創建一個html文件作為標准輸出。 要在vim中查看它,我只需要:

$ foo2html foo | vim -

vim將以標准輸入讀取啟動以供查看。 關閉vim后,命令將返回。

是否有一些命令行開關組合可以使google-chrome做到這一點?

不,我不這么認為。 但是您可以通過臨時文件來代替:

TEMPFILE=`tempfile` && foo2html foo > $TEMPFILE && google-chrome $TEMPFILE

只需使用數據URI

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

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

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

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

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

可在類似debian的系統上從coreutils獲得base64命令

sudo apt-get install coreutils

如果您沒有安裝coreutils或無法安裝新軟件包,則可以使用python模塊base64(幾乎所有發行版都具有python)

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM