Created
June 24, 2011 08:30
-
-
Save marcinbunsch/1044437 to your computer and use it in GitHub Desktop.
Rails production prompt change as a Rails initializer
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
# Put this file in config/initializers/irb.rb | |
# Works in Rails 3.0+, should also work in 2.3 | |
# Override the IRB, to provide the Rails environment in the prompt | |
module IRB | |
class << self | |
def setup_with_prompt_override(ap_path) | |
setup_without_prompt_override(ap_path) | |
env = (Rails.env.to_sym == :production ? "\033[00;31mPRODUCTION\033[00m" : Rails.env) | |
IRB.conf[:PROMPT].keys.each do |prompt| | |
IRB.conf[:PROMPT][prompt][:PROMPT_I] = "(#{env}) " + IRB.conf[:PROMPT][prompt][:PROMPT_I].to_s | |
IRB.conf[:PROMPT][prompt][:PROMPT_C] = "(#{env}) " + IRB.conf[:PROMPT][prompt][:PROMPT_C].to_s | |
IRB.conf[:PROMPT][prompt][:PROMPT_S] = "(#{env}) " + IRB.conf[:PROMPT][prompt][:PROMPT_S].to_s | |
end | |
end | |
alias_method_chain :setup, :prompt_override | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI, this will break production 'rails s' in (at least) 3.2.8. Adding 'require IRB' before it makes it work.