Skip to content

Instantly share code, notes, and snippets.

@pbc
Forked from defunkt/browser
Created June 14, 2012 09:55
Show Gist options
  • Save pbc/2929376 to your computer and use it in GitHub Desktop.
Save pbc/2929376 to your computer and use it in GitHub Desktop.
pipe html to a browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo '<h1>hi mom!</h1>' | browser
# $ ron -5 man/rip.5.ron | browser
BROWSER=/usr/bin/firefox
if [ -t 0 ]; then
if [ -n "$1" ]; then
$BROWSER $1 < /dev/null &>/dev/null &
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
$BROWSER $f < /dev/null &>/dev/null &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment