Created
October 27, 2011 21:26
-
-
Save techpeace/1320930 to your computer and use it in GitHub Desktop.
Recent irbrc
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
require 'awesome_print' | |
require 'wirble' | |
# Print all output with awesome_print | |
module IRB | |
class Irb | |
def output_value | |
ap @context.last_value | |
end | |
end | |
end | |
# Make irb remember the last X lines from the previous session. | |
# from http://www.enriquedelgado.com/articles/2007/04/25/interactive-ruby-console-tip-remember-the-last-x-commands-even-after-logging-out | |
# I haven't decided what I think of this, yet. | |
# IRB.conf[:PROMPT_MODE] = :SIMPLE | |
# | |
require 'irb/completion' | |
IRB.conf[:AUTO_INDENT] = true | |
# if ENV['RAILS'].to_i == 1 | |
# require 'active_record' | |
# | |
# class ActiveRecord::Base | |
# def self.inspect_all(options = {:limit => nil}) | |
# puts find(:all, :limit => options[:limit]).map(&:to_yaml) | |
# end | |
# end | |
# end | |
# Simple regular expression helper | |
# show_regexp - stolen from the pickaxe | |
def show_regexp(a, re) | |
if a =~ re | |
"#{$`}<<#{$&}>>#{$'}" | |
else | |
"no match" | |
end | |
end | |
{:this => "is pretty cool"} | |
# Convenience method on Regexp so you can do | |
# /an/.show_match("banana") | |
class Regexp | |
def show_match(a) | |
show_regexp(a, self) | |
end | |
end | |
# print SQL to STDOUT | |
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
require 'logger' | |
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) | |
end | |
# Prompt behavior | |
ARGV.concat [ "--readline", "--prompt-mode", "simple" ] | |
# History | |
require 'irb/ext/save-history' | |
IRB.conf[:SAVE_HISTORY] = 100 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" | |
# Easily print methods local to an object's class | |
class Object | |
def local_methods | |
(methods - Object.instance_methods).sort | |
end | |
end | |
# Wirble Vibrant Ink theme | |
Wirble::Colorize.colors = { | |
# delimiter colors | |
:comma => :white, | |
:refers => :white, | |
# container colors (hash and array) | |
:open_hash => :white, | |
:close_hash => :white, | |
:open_array => :white, | |
:close_array => :white, | |
# object colors | |
:open_object => :light_red, | |
:object_class => :light_red, | |
:object_addr_prefix => :blue, | |
:object_line_prefix => :blue, | |
:close_object => :light_red, | |
# symbol colors | |
:symbol => :blue, | |
:symbol_prefix => :blue, | |
# string colors | |
:open_string => :green, | |
:string => :green, | |
:close_string => :green, | |
# misc colors | |
:number => :yellow, | |
:keyword => :light_red, | |
:class => :light_red, | |
:range => :white | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment