Skip to content

Instantly share code, notes, and snippets.

@lackac
Created September 7, 2011 08:10
Show Gist options
  • Save lackac/1200027 to your computer and use it in GitHub Desktop.
Save lackac/1200027 to your computer and use it in GitHub Desktop.
Use Pry everywhere
require 'rubygems'
# This makes pry itself and all pry gems available
$LOAD_PATH.push(*Dir["#{ENV['HOME']}/.prygems/gems/*/lib"]).uniq!
begin
# Use Pry everywhere
require 'pry'
rescue LoadError => e
end
if defined? Pry
Pry.start
exit
else
# Do your normal IRB stuff in case Pry is not available
end
# We do this here as well in case pry was not started through IRB,
# but for example from rails console with pry being in the Gemfile
$LOAD_PATH.push(*Dir["#{ENV['HOME']}/.prygems/gems/*/lib"]).uniq!
# Further Pry configuration
# vim FTW
Pry.config.editor = "mvim --nofork"
# My pry is polite
Pry.hooks = { :after_session => proc { puts "bye-bye" } }
# Prompt with ruby version
Pry.prompt = [
proc { |obj, nest_level| "#{RUBY_ENGINE}-#{RUBY_VERSION} (#{obj})#{":#{nest_level}" if nest_level > 0}> " },
proc { |obj, nest_level| "#{RUBY_ENGINE}-#{RUBY_VERSION} (#{obj})#{":#{nest_level}" if nest_level > 0}* " }
]
# etc.
alias prygem='gem install -i ~/.prygems'
alias pry='irb'
# You should install gems you want in your REPL with `prygem`:
#
# $ prygem pry pry-doc hirb coderay
@nappa32
Copy link

nappa32 commented Feb 9, 2015

shouldn't the bash / zshrc file be : irb=pry ?

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