Skip to content

Instantly share code, notes, and snippets.

@tomkersten
Created May 27, 2009 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomkersten/118758 to your computer and use it in GitHub Desktop.
Save tomkersten/118758 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'irb/completion'
require 'irb/ext/save-history'
require 'utility_belt'
IRB.conf[:SAVE_HISTORY] = 300
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
IRB.conf[:PROMPT_MODE] = :SIMPLE
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
# Just for Rails...
if rails_env = ENV['RAILS_ENV']
# Set up so named routes will work in ./script/console
require 'action_controller'
include ActionController::UrlWriter
default_url_options[:host] = "http://localhost:3000"
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment