.irbrc color coding Rails console by environment
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
# Add color coding based on Rails environment for safety | |
if defined? Rails | |
banner = if Rails.env.production? | |
"\e[41;97;1m #{Rails.env} \e[0m " | |
else | |
"\e[42;97;1m #{Rails.env} \e[0m " | |
end | |
# Build a custom prompt | |
IRB.conf[:PROMPT][:CUSTOM] = IRB.conf[:PROMPT][:DEFAULT].merge( | |
PROMPT_I: banner + IRB.conf[:PROMPT][:DEFAULT][:PROMPT_I], | |
) | |
# Use custom prompt by default | |
IRB.conf[:PROMPT_MODE] = :CUSTOM | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Relevant "docs" for customizing the IRB prompt: https://github.com/ruby/irb/blob/master/lib/irb.rb#L144-L233