Show Rails environment in Pry

31 Oct 2012

I believe that environment awareness is important. Especially when it comes to your Rails environment and mocking around in a production setting. Hence, I added the following lines to my Pry config (.pryrc) to have the prompt include the current environment.

if defined?(Rails)
  Pry.config.prompt = [proc { env }, "     | "]

def env
  Rails.env.production? ? "\e[1;31m#{Rails.env}\e[0m > " : "#{Rails.env} > "