Skip to content

Instantly share code, notes, and snippets.

@larryebaum
Forked from defunkt/browser
Created August 16, 2024 18:13
Show Gist options
  • Save larryebaum/f1dad7bdae3a8b40f405b518ad8e4420 to your computer and use it in GitHub Desktop.
Save larryebaum/f1dad7bdae3a8b40f405b518ad8e4420 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
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
@larryebaum
Copy link
Author

Installation:

brew install browser

Or, if you must:

sudo curl https://gist.githubusercontent.com/larryebaum/f1dad7bdae3a8b40f405b518ad8e4420/raw/21e65811a50b3cc8bb2b31c658279714657aab96/browser -o /usr/local/bin/browser
sudo chmod +x /usr/local/bin/browser

Usage

curl https://gist.githubusercontent.com/larryebaum/06289a66533986f172d8b1b8f56499c6/raw/a383262cb9a20d43289150ffe7127496ff49e888/basic.html | browser

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