/
irbrc
49 lines (40 loc) · 1.04 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
#!/usr/bin/env ruby
IRB.conf[:AUTO_INDENT] = true
require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 10_000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
[
'irbtools',
'active_support/all'
].each do |library|
begin
require library
rescue LoadError
puts "* Unable to load #{library}"
end
end
Time.zone = 'America/Vancouver' if Time.respond_to?(:zone=)
# Enable lambda prompts. http://twitter.com/acetoxy/status/26734736005
class IRB::Irb
alias original_prompt prompt
def prompt(prompt, ltype, indent, line_no)
prompt = prompt.call if prompt.respond_to?(:call)
original_prompt(prompt, ltype, indent, line_no)
end
end
def rails_console?
$PROGRAM_NAME == 'rails_console'
end
# E.g.:
# 12:23:15 >>
# DEV 12:23:15 >>
# https://github.com/henrik/dotfiles/blob/master/irbrc
IRB.conf[:PROMPT][:SIMPLE][:PROMPT_I] = lambda {
[
(rails_console? ? Rails.env.first(3).upcase : nil),
Time.now.strftime('%H:%M:%S'),
'>> '
].compact.join(' ')
}
IRB.conf[:PROMPT_MODE] = :SIMPLE