Skip to content

Instantly share code, notes, and snippets.

@HashNuke
Last active September 3, 2024 04:21
Show Gist options
  • Save HashNuke/f9f74c68168af26c1440a1f18e563cf4 to your computer and use it in GitHub Desktop.
Save HashNuke/f9f74c68168af26c1440a1f18e563cf4 to your computer and use it in GitHub Desktop.
Emoji-powered IRB prompts to differentiate between Rails environments

Add this to the .irbrc file in the rails app directory.

rails_env = "🤗"
if ENV['RAILS_ENV'] == 'production'
  rails_env = "🥶"
elsif ENV['RAILS_ENV'] == 'staging'
  rails_env = "🧘"
end

IRB.conf[:PROMPT][:RAILS_APP] = {
  :PROMPT_I=>"#{rails_env} %N(%m):%03n> ",
  :PROMPT_S=>"#{rails_env} %N(%m):%03n%l ",
  :PROMPT_C=>"#{rails_env} %N(%m):%03n* ",
  :RETURN=>"#{rails_env} => %s\n"
}
IRB.conf[:PROMPT_MODE] = :RAILS_APP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment