Skip to content

Instantly share code, notes, and snippets.

@codeprimate
Created December 8, 2009 17:58
Show Gist options
  • Save codeprimate/251853 to your computer and use it in GitHub Desktop.
Save codeprimate/251853 to your computer and use it in GitHub Desktop.
# ~/.irbrc
# Requires the following gems: wirble, hirb
#
# Hirb: http://tagaholic.me/hirb/doc/index.html
# Wirble: http://pablotron.org/software/wirble/
require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
IRB.conf[:PROMPT_MODE] = :SIMPLE
# Just for Rails...
if rails_env = ENV['RAILS_ENV']
rails_root = File.basename(Dir.pwd)
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:RAILS] = {
:PROMPT_I => "#{rails_root}> ",
:PROMPT_S => "#{rails_root}* ",
:PROMPT_C => "#{rails_root}? ",
: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
begin
# load wirble
require 'rubygems'
require 'wirble'
# start wirble (with color)
Wirble.init
Wirble.colorize
rescue LoadError => err
warn "Couldn't load Wirble: #{err}"
end
begin
# load Hirb
require 'hirb'
Hirb.enable
rescue LoadError => err
warn "Couldn't load Hirb: #{err}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment