Skip to content

Instantly share code, notes, and snippets.

@pgroudas
Created November 22, 2011 21:10
Show Gist options
  • Save pgroudas/1386976 to your computer and use it in GitHub Desktop.
Save pgroudas/1386976 to your computer and use it in GitHub Desktop.
Simple .irbrc
#!/usr/bin/ruby
require 'irb/completion'
require 'irb/ext/save-history'
require 'rubygems'
IRB.conf[:USE_READLINE] = true
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:AUTO_INDENT] = true
class Object
# list methods which aren't in superclass
def local_methods(obj = self)
(obj.methods - obj.class.superclass.instance_methods).sort
end
def ri(method = nil)
unless method && method =~ /^[A-Z]/ # if class isn't specified
klass = self.kind_of?(Class) ? name : self.class.name
method = [klass, method].compact.join('#')
end
puts `ri '#{method}'`
end
end
def r
reload!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment