Skip to content

Instantly share code, notes, and snippets.

@jabawack81
Last active March 25, 2019 10:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jabawack81/1b111022f1720ae71745b7589dd315c0 to your computer and use it in GitHub Desktop.
Save jabawack81/1b111022f1720ae71745b7589dd315c0 to your computer and use it in GitHub Desktop.
Rails environment in pry prompt
# 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