Home > irbrc

irbrc

Irbrc is a project mainly written in ..., based on the MIT license.

My .irbrc file (for the Interactive Ruby console, IRb)

= .irbrc

This is my .irbrc configuration file

== Where to place it?

Place it in your home directory (~/.irbrc) or you can symlink it from other folder like this:

$ cd ~ (or 'cd')
$ ln -s folder/where/you/cloned/this/repo/irbrc/dot_irbrc .irbrc

== Contents

=== Loaded libraries

  • rubygems (http://www.rubygems.com)
  • Wirble (http://pablotron.org/software/wirble/)
  • pp (http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/pp/rdoc/index.html)
  • irb/ext/save-history (http://ruby-doc.org/core/files/lib/irb/ext/save-history_rb.html)
  • ap (http://github.com/michaeldv/awesome_print)
  • mush (http://github.com/rafmagana/mush)

=== History

You'll need to create a file called .irb-save-history in your home directory for this to work

=== Prompt

I use a simple prompt for the IRb sessions

IRB.conf[:PROMPT_MODE] = :SIMPLE

And a customized one for Rails sessions

IRB.conf[:PROMPT][:RAILS] = {}

=== ActiveRecord log

This will print the log in the console.

IRB.conf[:IRB_RC] = Proc.new do
    logger = Logger.new(STDOUT)
    ActiveRecord::Base.logger = logger
    ...

=== IRb Helper methods

clear - clear the screen ri - it's a wrapper to the ri command-line ruby documentation utility

=== Rails-specific Helper methods

log_ar_to :record - Change the ActiveRecord's logger to log/record.log log_ac_to :controller - Change the ActiveController's logger to log/controller.log

=== Core Extensions

Object local_methods - shows the methods of an object getting rid of the Object.instance_methods eigenclass - please read about meta-programming in Ruby to_pboard - "some text".to_pboard copies "some text" to the Mac OS's default pasteboard (alias 'to_pb') paste - it pastes the content of the Mac OS's default pasteboard to_find - a wrapper to to_pboard :find ql - do you know the QuickLook feature on Mac OS? well, "path/to/folder_or_image".ql will show you the folder stats or the image, Ctrl-C will close it

Class class_methods defined_methods - returns a hash with two keys :instance (instance methods) and :class (class methods) metaclass - returns the eigenclass the "include" method is a public one to help to include modules easily.

=== Aliases q => exit cl => clear (helper method)

== Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright (c) 2010 Rafael Magaña. See LICENSE for details.

Previous:first_app