diff --git a/.irbrc b/.irbrc new file mode 100644 index 0000000..9fab231 --- /dev/null +++ b/.irbrc @@ -0,0 +1,71 @@ +#!/usr/bin/ruby +require 'irb/completion' +require 'irb/ext/save-history' + +IRB.conf[:SAVE_HISTORY] = 1000 +IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history" + +IRB.conf[:PROMPT_MODE] = :SIMPLE + +%w[rubygems looksee/shortcuts wirble].each do |gem| + begin + require gem + rescue LoadError + end +end + +class Object + # list methods which aren't in superclass + def local_methods(obj = self) + (obj.methods - obj.class.superclass.instance_methods).sort + end + + # print documentation + # + # ri 'Array#pop' + # Array.ri + # Array.ri :pop + # arr.ri :pop + 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 + system 'ri', method.to_s + end +end + +def copy(str) + IO.popen('pbcopy', 'w') { |f| f << str.to_s } +end + +def copy_history + history = Readline::HISTORY.entries + index = history.rindex("exit") || -1 + content = history[(index+1)..-2].join("\n") + puts content + copy content +end + +def paste + `pbpaste` +end + +load File.dirname(__FILE__) + '/.railsrc' if ($0 == 'irb' && ENV['RAILS_ENV']) || ($0 == 'script/rails' && Rails.env) + +require "rubygems" +require "awesome_print" + +unless IRB.version.include?('DietRB') + IRB::Irb.class_eval do + def output_value + ap @context.last_value + end + end +else # MacRuby + IRB.formatter = Class.new(IRB::Formatter) do + def inspect_object(object) + object.ai + end + end.new +end diff --git a/bash/env b/bash/env index dbdf8e9..80a5525 100644 --- a/bash/env +++ b/bash/env @@ -2,7 +2,7 @@ export PATH="~/bin:~/.bin:/usr/local/homebrew/bin:/usr/local/bin:/usr/local/sbin # Set PATH, CDPATH, EDITOR, etc. -export EDITOR="mate_wait" +export EDITOR="subl -w" export CLICOLOR=1 export LSCOLORS=Exfxcxdxbxegedabagacad