added pipe-able browser hack from defunkt

pull/22/head
Florian Baumann 2010-11-10 20:25:40 +01:00
parent bd22485639
commit 02d65afdcb
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# based on https://gist.github.com/318247
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo "<h1>hi mom!</h1>" | browser
# $ ron -5 man/rip.5.ron | browser
function browser() {
if [ -t 0 ]; then
if [ -n "$1" ]; then
open $1
else
cat <<usage
Usage: browser
pipe html to a browser
$ echo '<h1>hi mom!</h1>' | browser
$ ron -5 man/rip.5.ron | browser
usage
fi
else
f="/tmp/browser.$RANDOM.html"
cat /dev/stdin > $f
open $f
fi
}