forked from joaovitor/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirbrc
97 lines (82 loc) · 2.02 KB
/
irbrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# irbrc merged
# http://eustaquiorangel.com/posts/552
# http://gist.github.com/86875
require "irb/completion" # activate default completion
require 'irb/ext/save-history' # activate default history
require "tempfile" # used for Vim integration
require 'pp'
# save history using built-in options
IRB.conf[:SAVE_HISTORY] = 10000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
# auto-indent
IRB.conf[:AUTO_INDENT]=true
# try to load rubygems
begin
require "rubygems"
rescue LoadError => e
puts "Seems you don't have Rubygems installed: #{e}"
end
# let there be colors
# just use Wirble for colors, since some enviroments dont have
# rubygems and wirble installed
begin
require "wirble"
Wirble.init(:skip_prompt=>true,:skip_history=>true)
Wirble.colorize
rescue LoadError => e
puts "Seems you don't have Wirble installed: #{e}"
end
# enabling Hirb
begin
require 'hirb'
Hirb.enable
rescue LoadError => e
puts "Seems you don't have Hirb installed: #{e}"
end
# configure vim
@irb_temp_code = nil
def vim(file=nil)
file = file || @irb_temp_code || Tempfile.new("irb_tempfile").path+".rb"
system("vim #{file}")
if(File.exists?(file) && File.size(file)>0)
Object.class_eval(File.read(file))
@irb_temp_code = file
else
"No file loaded."
end
rescue => e
puts "Error on vim: #{e}"
end
class Object
# get all the methods for an object that aren't basic methods from Object
def my_methods
(methods - Object.instance_methods).sort
end
end
# from http://themomorohoax.com/2009/03/27/irb-tip-load-files-faster
def ls
%x{ls}.split("\n")
end
def cd(dir)
Dir.chdir(dir)
Dir.pwd
end
def pwd
Dir.pwd
end
# also from http://themomorohoax.com/2009/03/27/irb-tip-load-files-faster
def rl(file_name = nil)
if file_name.nil?
rl(@recent)
else
puts "No recent file to reload"
end
else
file_name += '.rb' unless file_name =~ /\.rb/
@recent = file_name
load "#{file_name}"
end
end
alias p pp
alias quit exit