Skip to content

Instantly share code, notes, and snippets.

@aalin
Created October 8, 2010 10:05
Show Gist options
  • Select an option

  • Save aalin/616586 to your computer and use it in GitHub Desktop.

Select an option

Save aalin/616586 to your computer and use it in GitHub Desktop.
Show rails environment in the rails console
class IRB::Irb
alias :original_prompt :prompt
def prompt(prompt, ltype, indent, line_no)
prompt = prompt.call if prompt.respond_to?(:call)
original_prompt(prompt, ltype, indent, line_no)
end
end
IRB.conf[:PROMPT_MODE] = :RAILS_ENV
IRB.conf[:PROMPT][:RAILS_ENV] = IRB.conf[:PROMPT][:CLASSIC].merge(:PROMPT_I => lambda { (defined?(Rails) ? "#{Rails.env} " : "") + "%N(%m):%03n:%i> " })
@grosser
Copy link
Copy Markdown

grosser commented Mar 22, 2017

FYI gem 'marco-polo' does about the same and no custom hacks required :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment