Never forget the environment you are in.
# .irbrc
module ColorString
refine String do
def cyan = "\e[36m#{self}\e[0m"
def bg_red = "\e[41m#{self}\e[0m"
def bg_yellow = "\e[43m#{self}\e[0m"
def bg_green = "\e[42m#{self}\e[0m"
end
end
if defined?(Rails)
using ColorString
if Rails.env.production? || Rails.env.staging?
IRB.conf[:SAVE_HISTORY] = false
end
project_name = File.basename(Dir.pwd).cyan
environment = case Rails.env
when "development"
Rails.env.bg_green
when "staging"
Rails.env.bg_yellow
when "production"
Rails.env.bg_red
end
prompt = "#{project_name} [#{environment}]"
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:RAILS] = {
PROMPT_I: "#{prompt} %03n > ",
PROMPT_S: "#{prompt} %03n * ",
PROMPT_C: "#{prompt} %03n ? ",
RETURN: "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :RAILS
end
begin
require "awesome_print"
AwesomePrint.irb!
rescue
end