Skip to content

Instantly share code, notes, and snippets.

@phansch phansch/.pryrc
Last active Aug 21, 2018

Embed
What would you like to do?
Colored Pry prompt including Rails environment and app name
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}> " }
@phansch

This comment has been minimized.

Copy link
Owner Author

phansch commented Feb 2, 2017

How it looks like:

selection_220
selection_218
selection_219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.