Skip to content

Instantly share code, notes, and snippets.

@straydogstudio
Created June 13, 2012 20:07
Show Gist options
  • Save straydogstudio/2926196 to your computer and use it in GitHub Desktop.
Save straydogstudio/2926196 to your computer and use it in GitHub Desktop.
IRB: Simple irb with gems loaded outside of Gemfile
# switch default editor for pry to sublime text
Pry.config.editor = "subl"
# format prompt to be <Rails version>@<ruby version>(<object>)>
Pry.config.prompt = proc do |obj, level, _|
prompt = "\e[1;30m"
prompt << "#{Rails.version} @ " if defined?(Rails)
prompt << "#{RUBY_VERSION}"
"#{prompt} (#{obj}:#{level})>\e[0m"
end
# break out of bundler so we can load gems outside of the Gemfile
if defined? Bundler
Gem.post_reset_hooks.reject! { |hook| hook.source_location.first =~ %r{/bundler/} }
Gem::Specification.reset
load 'rubygems/custom_require.rb'
end
# use awesome print for all objects in pry
begin
require 'awesome_print'
Pry.config.print = proc { |output, value| output.puts "=> #{ap value}" }
rescue
puts "=> Unable to load awesome_print, please type 'gem install awesome_print' or 'sudo gem install awesome_print'."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment