Last active
August 21, 2018 11:30
-
-
Save phansch/7b28629557360a05f4502e446c863786 to your computer and use it in GitHub Desktop.
Colored Pry prompt including Rails environment and app name
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
def formatted_env | |
case Rails.env | |
when 'production' | |
bold_upcased_env = Pry::Helpers::Text.bold(Rails.env.upcase) | |
Pry::Helpers::Text.red(bold_upcased_env) | |
when 'staging' | |
Pry::Helpers::Text.yellow(Rails.env) | |
when 'development' | |
Pry::Helpers::Text.green(Rails.env) | |
else | |
Rails.env | |
end | |
end | |
# This may need to be adjusted for Rails < 4 | |
def app_name | |
Rails.application.class.parent.name.underscore | |
end | |
Pry.config.prompt = proc { |obj, nest_level, _| "[#{app_name}][#{formatted_env}] #{obj}:#{nest_level}> " } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How it looks like: