Skip to content

Instantly share code, notes, and snippets.

@henrik
Created December 23, 2008 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save henrik/39503 to your computer and use it in GitHub Desktop.
Save henrik/39503 to your computer and use it in GitHub Desktop.
# http://pablotron.org/software/wirble/
# Provides "ri", history survives restart etc
require 'rubygems'
require 'wirble'
Wirble.init
# http://www.quotedprintable.com/2007/9/13/my-irbrc
# Show rails root in script/console prompt
require 'irb/completion'
IRB.conf[:PROMPT_MODE] = :SIMPLE
# Just for Rails...
if rails_env = ENV['RAILS_ENV']
rails_root = File.basename(Dir.pwd)
prompt = "#{rails_root}[#{rails_env.sub('production', 'prod').sub('development', 'dev')}]"
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:RAILS] = {
:PROMPT_I => "#{prompt}>> ",
:PROMPT_S => "#{prompt}* ",
:PROMPT_C => "#{prompt}? ",
:RETURN => "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :RAILS
# Called after the irb session is initialized and Rails has
# been loaded (props: Mike Clark).
IRB.conf[:IRB_RC] = Proc.new do
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.instance_eval { alias :[] :find }
end
end
# Enables items.map(&:name) in regular irb
class Symbol
def to_proc
lambda {|*args| args.shift.__send__(self, *args)}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment