Last active
March 25, 2019 10:26
-
-
Save jabawack81/1b111022f1720ae71745b7589dd315c0 to your computer and use it in GitHub Desktop.
Rails environment in pry prompt
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
# frozen_string_literal: true | |
# config/initializers/pry.rb | |
old_prompt = Pry.config.prompt | |
env = case Rails.env | |
when "production" then Pry::Helpers::Text.red(Rails.env.upcase) | |
when "staging" then Pry::Helpers::Text.yellow(Rails.env.upcase) | |
when "development" then Pry::Helpers::Text.green(Rails.env.upcase) | |
when "test" then Pry::Helpers::Text.blue(Rails.env.upcase) | |
else Pry::Helpers::Text.magenta("NO IDEA") | |
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