Skip to content

Instantly share code, notes, and snippets.

@draxaris1010
Forked from defunkt/browser
Created May 4, 2024 08:15
Show Gist options
  • Select an option

  • Save draxaris1010/f6e3c4bd0699a98357128e69f97fdc6b to your computer and use it in GitHub Desktop.

Select an option

Save draxaris1010/f6e3c4bd0699a98357128e69f97fdc6b 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=$(mktemp -t browser.XXXXX.html)
cat /dev/stdin > "$f"
open "$f"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment