Last active
December 28, 2015 10:59
-
-
Save benolee/7490596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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