Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created March 1, 2010 10:01

Revisions

  1. defunkt revised this gist Feb 28, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion browser
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # Usage: browser
    # pipe html to a browser
    # e.g.
    # $ echo "<h1>hi mom!</h1>" | browser
    # $ echo '<h1>hi mom!</h1>' | browser
    # $ ron -5 man/rip.5.ron | browser

    if [ -t 0 ]; then
  2. defunkt revised this gist Mar 9, 2010. 1 changed file with 22 additions and 18 deletions.
    40 changes: 22 additions & 18 deletions browser
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,25 @@
    #!/bin/sh -e
    #
    # Usage: browser
    # pipe html to a browser
    # e.g.
    # $ echo "<h1>hi mom!</h1>" | 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
    cat <<usage
    Usage: browser
    pipe html to a browser
    $ 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
    else
    f="/tmp/browser.$RANDOM.html"
    cat /dev/stdin > $f
    open $f
    fi
    else
    f="/tmp/browser.$RANDOM.html"
    cat /dev/stdin > $f
    open $f
    fi
  3. defunkt revised this gist Mar 2, 2010. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions browser
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@
    # pipe html to a browser
    # e.g.
    # $ echo "<h1>hi mom!</h1>" | browser
    # $ ron -5 man/rip.5.ron | browser

    if [ -t 0 ]; then
    cat <<usage
  4. defunkt revised this gist Mar 1, 2010. 1 changed file with 19 additions and 23 deletions.
    42 changes: 19 additions & 23 deletions browser
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,20 @@
    #!/usr/bin/env ruby
    #
    # Usage: browser
    # pipe html to a browser
    # e.g.
    # $ echo "<h1>hi mom!</h1>" | browser
    # $ ron -5 man/rip.5.ron | browser

    if $stdin.tty?
    puts <<-usage
    Usage: browser
    pipe html to a browser
    $ echo '<h1>hi mom!</h1>' | browser
    $ ron -5 man/rip.5.ron | browser
    #!/bin/sh -e
    #
    # Usage: browser
    # pipe html to a browser
    # e.g.
    # $ echo "<h1>hi mom!</h1>" | browser

    if [ -t 0 ]; then
    cat <<usage
    Usage: browser
    pipe html to a browser
    $ echo '<h1>hi mom!</h1>' | browser
    $ ron -5 man/rip.5.ron | browser
    usage
    else
    require 'tempfile'
    tmp = Tempfile.new(['', '.html'])
    File.open(tmp.path, "w+") do |f|
    f.puts $stdin.read
    end
    exec "open #{tmp.path}"
    end
    else
    f="/tmp/browser.$RANDOM.html"
    cat /dev/stdin > $f
    open $f
    fi
  5. defunkt revised this gist Mar 1, 2010. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions browser
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@
    # pipe html to a browser
    # e.g.
    # $ echo "<h1>hi mom!</h1>" | browser
    # $ ron -5 man/rip.5.ron | browser

    if $stdin.tty?
    puts <<-usage
  6. defunkt revised this gist Mar 1, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions browser
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/env ruby
    #
    # Usage: browser
    # pipe html to a browser
    # pipe html to a browser
    # e.g.
    # $ echo "<h1>hi mom!</h1>" | browser

    @@ -20,4 +20,4 @@ else
    f.puts $stdin.read
    end
    exec "open #{tmp.path}"
    end
    end
  7. defunkt created this gist Mar 1, 2010.
    23 changes: 23 additions & 0 deletions browser
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/usr/bin/env ruby
    #
    # Usage: browser
    # pipe html to a browser
    # e.g.
    # $ echo "<h1>hi mom!</h1>" | browser

    if $stdin.tty?
    puts <<-usage
    Usage: browser
    pipe html to a browser
    $ echo '<h1>hi mom!</h1>' | browser
    $ ron -5 man/rip.5.ron | browser
    usage
    else
    require 'tempfile'
    tmp = Tempfile.new(['', '.html'])
    File.open(tmp.path, "w+") do |f|
    f.puts $stdin.read
    end
    exec "open #{tmp.path}"
    end