Skip to content

Instantly share code, notes, and snippets.

@phansch
Last active August 21, 2018 11:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save phansch/7b28629557360a05f4502e446c863786 to your computer and use it in GitHub Desktop.
Save phansch/7b28629557360a05f4502e446c863786 to your computer and use it in GitHub Desktop.
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
Copy link
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