Created
August 19, 2010 20:10
-
-
Save mkdynamic/538784 to your computer and use it in GitHub Desktop.
my .irbrc file
This file contains 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
# rubygems | |
require 'rubygems' | |
# active_support from rails | |
require 'active_support' unless ENV['RAILS_ENV'] | |
# wirble -- colors + more | |
require 'wirble' | |
module Wirble::Colorize::Color | |
class << self | |
def brighten(s) | |
s.sub(/^(\d);3(\d)$/, "\\1;9\\2") # replaces X;3Y with X;9Y | |
end | |
def escape_with_brightening(key) | |
COLORS.key?(key) && "\033[#{Wirble::Colorize::Color.brighten(COLORS[key])}m" | |
end | |
alias_method :escape_without_brightening, :escape | |
alias_method :escape, :escape_with_brightening | |
end | |
end | |
colors = Wirble::Colorize.colors.merge({ | |
# delimiter colors | |
:comma => :green, | |
:refers => :green, | |
# container colors (hash and array) | |
:open_hash => :green, | |
:close_hash => :green, | |
:open_array => :green, | |
:close_array => :green, | |
# object colors | |
:open_object => :light_red, | |
:object_class => :white, | |
:object_addr_prefix => :white, | |
:object_line_prefix => :white, | |
:close_object => :light_red, | |
# symbol colors | |
:symbol => :yellow, | |
:symbol_prefix => :yellow, | |
# string colors | |
:open_string => :red, | |
:string => :cyan, | |
:close_string => :red, | |
# misc colors | |
:number => :cyan, | |
:keyword => :green, | |
:class => :light_green, | |
:range => :red, | |
}) | |
Wirble::Colorize.colors = colors | |
Wirble.init | |
Wirble.colorize | |
# tab completion | |
require 'irb/completion' | |
require 'map_by_method' | |
require 'what_methods' | |
IRB.conf[:USE_READLINE] = true | |
# pretty print | |
require 'pp' | |
# misc. irb settings | |
IRB.conf[:AUTO_INDENT] = true | |
IRB.conf[:PROMPT_MODE] = :SIMPLE | |
# easily print methods local to an object's class | |
class Object | |
def local_methods | |
(methods - Object.instance_methods).sort | |
end | |
end | |
# rails specific | |
if rails_env = ENV['RAILS_ENV'] | |
require 'hirb' | |
Hirb::View.enable | |
# Called after the irb session is initialized and Rails has | |
# been loaded (props: Mike Clark). | |
if ENV['SC_LOG'] == 'true' && !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
require 'logger' | |
puts "- Logging to STDOUT" | |
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) | |
end | |
# Shortcut to reset | |
def reset | |
Dispatcher.reset_application! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment