forked from jonparis/config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.irbrc
64 lines (56 loc) · 1.5 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
# Interactive Ruby console configuration
IRB_START_TIME = Time.now
# Print to yaml format with "y"
require 'yaml'
# Pretty printing
require 'pp'
# Ability to load rubygem modules
require 'rubygems'
# Tab completion
require 'irb/completion'
# Save irb sessions to history file
require 'irb/ext/save-history'
# Not stdlib
require 'map_by_method'
require 'what_methods'
# For printing time in session
require 'duration'
# For coloration
require 'wirble'
# Include line numbers and indent levels:
IRB.conf[:PROMPT][:SHORT] = {
:PROMPT_C=>"%03n:%i* ",
:RETURN=>"%s\n",
:PROMPT_I=>"%03n:%i> ",
:PROMPT_N=>"%03n:%i> ",
:PROMPT_S=>"%03n:%i%l "
}
IRB.conf[:PROMPT_MODE] = :SHORT
# Adds readline functionality
IRB.conf[:USE_READLINE] = true
# Auto indents suites
IRB.conf[:AUTO_INDENT] = true
# Where history is saved
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
# How many lines to save
IRB.conf[:SAVE_HISTORY] = 2000
# Turn turn on colorization, off other wirble wierdness
Wirble.init(:skip_prompt => true, :skip_history => true)
Wirble.colorize
# Quick benchmarking facility
# Based on rue's irbrc => http://pastie.org/179534
def quick(repetitions=100, &block)
require 'benchmark'
Benchmark.bmbm do |b|
b.report {repetitions.times &block}
end
nil
end
# Return only the methods not present on basic objects
class Object
def interesting_methods
(self.methods - Object.new.methods).sort
end
end
# Prints how long the session has been open upon exit
at_exit { puts Duration.new(Time.now - IRB_START_TIME) }