Created
May 29, 2014 17:56
-
-
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.
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
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