Created
December 23, 2008 23:10
-
-
Save henrik/39503 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
# 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