Skip to content

Commit

Permalink
add .irbrc, udpate editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Dobzinski committed Jun 8, 2012
1 parent c530a62 commit f9d5fa8
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
71 changes: 71 additions & 0 deletions .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
2 changes: 1 addition & 1 deletion bash/env
Expand Up @@ -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

Expand Down

0 comments on commit f9d5fa8

Please sign in to comment.