Skip to content

Instantly share code, notes, and snippets.

@benolee
Last active December 28, 2015 10:59
Show Gist options
  • Save benolee/7490596 to your computer and use it in GitHub Desktop.
Save benolee/7490596 to your computer and use it in GitHub Desktop.
# use from pry or whatever. must have bundler loaded.
# `gem install bcat` beforehand. it doesn't have to be in your gemfile.
# example: "hello from ruby".bcat #=> opens in default web browser
class String
def bcat
pull, push = IO.pipe
Bundler.with_original_env do
fork do
push.close
STDIN.reopen pull
exec "bcat"
exit 1
end
end
pull.close
push.write self
push.close
self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment