Skip to content

Instantly share code, notes, and snippets.

@robertsosinski
Created December 31, 2012 04:12
Show Gist options
  • Save robertsosinski/4417305 to your computer and use it in GitHub Desktop.
Save robertsosinski/4417305 to your computer and use it in GitHub Desktop.
Color Pry prompt according to environment, put this at the bottom of your config/environment.rb file and specify "prompt_color" in the config/<environment> file with config.prompt_color = <environment>.
# Color Pry prompt according to environment
old_prompt = Pry.config.prompt
color = {
:red => "31m",
:green => "32m",
:yellow => "33m",
:blue => "34m",
:purple => "35m",
:cyan => "36m"
}
prompt_color = color[(Pos::Application.config.prompt_color rescue nil)] || color[:red]
Pry.config.prompt = [
proc {|a,b,c| "\e[#{prompt_color}#{(Rails.env)}\e[0m #{old_prompt.first.call(a,b,c)}"},
proc {|a,b,c| "\e[#{prompt_color}#{(Rails.env)}\e[0m #{old_prompt.second.call(a,b,c)}"},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment