Skip to content

Instantly share code, notes, and snippets.

@esparkman
Created January 6, 2021 16:23
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 esparkman/26917aa875a9fb46d9dfd49f9e394820 to your computer and use it in GitHub Desktop.
Save esparkman/26917aa875a9fb46d9dfd49f9e394820 to your computer and use it in GitHub Desktop.
Environment Banners for Rails console + IRB
# .irbrc credit to Matt Swanson @_swanson
# 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
# Builda 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