Created
January 4, 2016 21:33
-
-
Save javidjamae/ca4a40a642bf957cae60 to your computer and use it in GitHub Desktop.
How to configure pry to show the environment name in the prompt
This file contains hidden or 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
# This file would go in config/initializers/pry.rb in a Rails project | |
old_prompt = Pry.config.prompt | |
env_str = "#{Rails.application.class.parent}-#{Rails.env}".upcase | |
if Rails.env.production? | |
# Can't do this because it messes with bash history for some reason | |
# env = Pry::Helpers::Text.red(env_str) | |
env = "\001\e[0;31m\002#{env_str}\001\e[0m\002" | |
else | |
# Can't do this because it messes with bash history for some reason | |
# env = Pry::Helpers::Text.green(env_str) | |
env = "\001\e[0;32m\002#{env_str}\001\e[0m\002" | |
end | |
Pry.config.prompt = [ | |
proc {|*a| "#{env} #{old_prompt.first.call(*a)}"}, | |
proc {|*a| "#{env} #{old_prompt.second.call(*a)}"}, | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment