Skip to content

Instantly share code, notes, and snippets.

@ghedo
Created Mar 10, 2012
Embed
What would you like to do?
Pipe stuff to the browser
#!/bin/sh -e
# Usage: bpipe [-h|--html]
# Pipe stuff to the browser
if [ -t 0 ]; then
echo "Usage: echo '<h1>some stuff</h1>' | bpipe"
else
opt=`getopt -o h --long html -n bpipe -- "$@"`
eval set -- "$opt"
case "$1" in
-h|--html) temp=`mktemp --suffix=.html` ;;
--) break ;;
esac
if [ -z "$temp" ]; then
temp=`mktemp`
fi
cat /dev/stdin > $temp
sensible-browser $temp # would work with xdg-open and open too
rm $temp
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment