Skip to content

Instantly share code, notes, and snippets.

@nz
Created May 29, 2014 17:56
Show Gist options
  • Save nz/288446fd8514b2b95e0e to your computer and use it in GitHub Desktop.
Save nz/288446fd8514b2b95e0e to your computer and use it in GitHub Desktop.
My ~/.irbrc with the Rails app name and environment. A useful bit of paranoia to help prevent operator errors.
if defined?(Rails) && Rails.env
reset = "\e[0m"
color = case Rails.env
when 'development', 'test'
"\e[36m" # cyan
else
"\e[31m" # magenta
end
app_name_env = "#{Rails.application.class.parent_name.underscore}"
app_name_env << "#{reset}:#{color}#{Rails.env}#{reset}"
IRB.conf[:PROMPT][:RAILS_ENV] = {
:PROMPT_I => "%N(#{app_name_env}):%03n:%i> ",
:PROMPT_N => "%N(#{app_name_env}):%03n:%i> ",
:PROMPT_S => "%N(#{app_name_env}):%03n:%i%l ",
:PROMPT_C => "%N(#{app_name_env}):%03n:%i* ",
:RETURN => "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :RAILS_ENV
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment