Skip to content

Instantly share code, notes, and snippets.

@boertel
Forked from defunkt/browser
Last active August 29, 2015 14:04
Show Gist options
  • Save boertel/a438eae2c962636e0915 to your computer and use it in GitHub Desktop.
Save boertel/a438eae2c962636e0915 to your computer and use it in GitHub Desktop.
#!/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
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 -a "/Applications/Google Chrome.app" $f
fi
@boertel
Copy link
Author

boertel commented Aug 5, 2014

sudo curl https://gist.githubusercontent.com/boertel/a438eae2c962636e0915/raw/054d1b26ef625009302214139e5153f8885fc436/browser -o /usr/local/bin/browser
sudo chmod +x !$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment