Skip to content

Instantly share code, notes, and snippets.

@czj
Created September 29, 2011 15:43
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czj/1251031 to your computer and use it in GitHub Desktop.
Save czj/1251031 to your computer and use it in GitHub Desktop.
.irbrc that runs Pry instead of IRB
# This script comes from Pry Everywhere by Luca Pette
# http://lucapette.com/pry/pry-everywhere/
# https://github.com/carlhuda/bundler/issues/183#issuecomment-1149953
if defined?(::Bundler)
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
$LOAD_PATH << gem_path
end
end
end
# Use Pry everywhere
require "rubygems"
require 'pry'
Pry.start
exit
@sheerun
Copy link

sheerun commented Feb 5, 2012

I use following one-liner because it leaves irb command unchanged and bundle console runs whatever you have in Gemfile (eg. bundle console development). And use pry if you want repl without Gemfile.

echo "Pry.start || exit rescue LoadError" > ~/.irbrc

@max-reznichenko
Copy link

Thanks for sharing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment