Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Oren Dobzinski
committed
Jun 8, 2012
1 parent
c530a62
commit f9d5fa8
Showing
2 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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