Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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 dolzenko/ba9f14c104a105ee46a13ced19a18332 to your computer and use it in GitHub Desktop.
Save dolzenko/ba9f14c104a105ee46a13ced19a18332 to your computer and use it in GitHub Desktop.
Rails production prompt change as a Rails initializer
# 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