Skip to content
Newer
Older
100644 59 lines (50 sloc) 1.23 KB
edca541 @oc Updates ...
authored
1 #!/usr/bin/ruby
2 require 'irb/completion'
3 require 'irb/ext/save-history'
4
5 IRB.conf[:SAVE_HISTORY] = 1000
6 IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
7 IRB.conf[:PROMPT_MODE] = :SIMPLE
8
9 %w[rubygems looksee/shortcuts wirble].each do |gemfile|
10 begin
11 require gemfile
12 rescue LoadError
13 puts "Couldn't load #{gemfile}"
14 end
15 end
16
17 if defined?(Wirble)
18 Wirble.init
19 Wirble.colorize
20 end
21
22 class Object
23 # list methods which aren't in superclass
24 def local_methods(obj = self)
25 (obj.methods - obj.class.superclass.instance_methods).sort
26 end
27
28 # print documentation
29 #
30 # ri 'Array#pop'
31 # Array.ri
32 # Array.ri :pop
33 # arr.ri :pop
34 def ri(method = nil)
35 unless method && method =~ /^[A-Z]/ # if class isn't specified
36 klass = self.kind_of?(Class) ? name : self.class.name
37 method = [klass, method].compact.join('#')
38 end
39 system 'ri', method.to_s
40 end
41 end
42
43 def copy(str)
44 IO.popen('pbcopy', 'w') { |f| f << str.to_s }
45 end
46
47 def copy_history
48 history = Readline::HISTORY.entries
49 index = history.rindex("exit") || -1
50 content = history[(index+1)..-2].join("\n")
51 puts content
52 copy content
53 end
54
55 def paste
56 `pbpaste`
57 end
58
59 #load File.dirname(__FILE__) + '/.railsrc' if $0 == 'irb' && ENV['RAILS_ENV']
Something went wrong with that request. Please try again.