-
-
Save marcoshack/579133 to your computer and use it in GitHub Desktop.
irbrc
This file contains hidden or 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
| #making .irbrc posted at http://www.tech-angels.fr/post/963080350/improve-irb-and-fix-it-on-mac-os-x | |
| #work with rails3 | |
| require 'rubygems' | |
| #rails3: be sure to include wirble and hirb in your Gemfile | |
| require 'wirble' | |
| require 'hirb' | |
| Wirble.init | |
| Wirble.colorize | |
| # hirb (active record output format in table) | |
| Hirb::View.enable | |
| # IRB Options | |
| IRB.conf[:AUTO_INDENT] = true | |
| IRB.conf[:SAVE_HISTORY] = 1000 | |
| IRB.conf[:EVAL_HISTORY] = 200 | |
| #rails2 | |
| if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
| # Log to STDOUT if in Rails | |
| require 'logger' | |
| RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) | |
| #IRB.conf[:USE_READLINE] = true | |
| # Display the RAILS ENV in the prompt | |
| # ie : [Development]>> | |
| IRB.conf[:PROMPT][:CUSTOM] = { | |
| :PROMPT_N => "[#{ENV["RAILS_ENV"].capitalize}]>> ", | |
| :PROMPT_I => "[#{ENV["RAILS_ENV"].capitalize}]>> ", | |
| :PROMPT_S => nil, | |
| :PROMPT_C => "?> ", | |
| :RETURN => "=> %s\n" | |
| } | |
| # Set default prompt | |
| IRB.conf[:PROMPT_MODE] = :CUSTOM | |
| #rails3 | |
| elsif defined?(Rails) | |
| require 'logger' | |
| Rails.logger=Logger.new(STDOUT) | |
| #IRB.conf[:USE_READLINE] = true | |
| # Display the RAILS ENV in the prompt | |
| # ie : [Development]>> | |
| IRB.conf[:PROMPT][:CUSTOM] = { | |
| :PROMPT_N => "[#{Rails.env.capitalize}]>> ", | |
| :PROMPT_I => "[#{Rails.env.capitalize}]>> ", | |
| :PROMPT_S => nil, | |
| :PROMPT_C => "?> ", | |
| :RETURN => "=> %s\n" | |
| } | |
| # Set default prompt | |
| IRB.conf[:PROMPT_MODE] = :CUSTOM | |
| end | |
| # We can also define convenient methods (credits go to thoughtbot) | |
| def me | |
| User.find_by_email("me@gmail.com") | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment