Created
May 5, 2009 18:28
-
-
Save jaredatron/107109 to your computer and use it in GitHub Desktop.
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
| IRB.conf[:AUTO_INDENT] = true | |
| IRB.conf[:EDITOR] = :mate | |
| require 'rubygems' | |
| require 'utility_belt' | |
| %w(google interactive_editor command_history with).each{ |t| require "utility_belt/#{t}" } | |
| require 'wirble' | |
| require 'pp' | |
| WIRBLE_OPTIONS = { | |
| :history_size => 1000, | |
| :colorize => true, | |
| :colors => { | |
| :open_hash => :green, | |
| :close_hash => :green, | |
| :string => :blue, | |
| }, | |
| } | |
| # Easily print methods local to an object's class | |
| class Object | |
| # method inspection | |
| def local_methods | |
| (methods - Object.instance_methods).sort | |
| end | |
| # clears the screen | |
| def clear | |
| system('clear') | |
| nil | |
| end | |
| # opens a string in your prefered editor | |
| def e(*args) | |
| content = args.join("\n") | |
| require 'tempfile' unless defined? Tempfile | |
| Tempfile.open('irb') do |tempfile| | |
| tempfile.write content | |
| tempfile.flush | |
| `#{IRB.conf[:EDITOR]} -w #{tempfile.path}` | |
| end | |
| content | |
| end | |
| end | |
| alias c clear | |
| # http://www.quotedprintable.com/2007/9/13/my-irbrc | |
| # Show rails root in script/console prompt | |
| require 'irb/completion' | |
| IRB.conf[:PROMPT_MODE] = :SIMPLE | |
| # Enables items.map(&:name) in regular irb | |
| class Symbol | |
| def to_proc | |
| lambda {|*args| args.shift.__send__(self, *args)} | |
| end | |
| end | |
| # Log to STDOUT if in Rails | |
| if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
| require 'logger' | |
| RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) | |
| end | |
| #load ~/.irbrc_rails | |
| load File.expand_path('~/.irbrc_rails') if File.exists?( File.expand_path('~/.irbrc_rails') ) | |
| #load .irbrc | |
| load File.expand_path('./.irbrc') if File.exists?( File.expand_path('./.irbrc') ) and File.expand_path('./.irbrc') != File.expand_path('~/.irbrc') | |
| Wirble.init(WIRBLE_OPTIONS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment