-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.irbrc
55 lines (46 loc) · 1.42 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
# `edit` command opens files in your editor
ENV['EDITOR'] = 'code'
IRB.conf[:SAVE_HISTORY] = 10000
IRB.conf[:INSPECT_MODE] = :pp
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:COMPLETOR] = :type
if Gem::Version.new(Reline::VERSION) >= Gem::Version.new('0.4.0')
Reline::Face.config(:completion_dialog) do |conf|
# Slightly lighter black than :black ('#222121')
default_background_color = '#2C2B2B'
conf.define :default, foreground: :white, background: default_background_color
conf.define :enhanced, foreground: '#FFFFFF', background: '#005bbb'
conf.define :scrollbar, foreground: :gray, background: default_background_color
end
else
# Disable auto completion because completion text is difficult to see.
IRB.conf[:USE_AUTOCOMPLETE] = false
end
puts RUBY_DESCRIPTION
require 'csv'
require 'date'
require 'json'
require 'time'
require 'yaml'
# === Reline ===
class Reline::LineEditor
private def incremental_search_history(_key)
# Monkey Patch Ctrl-R
# https://github.com/peco/peco
code = IO.popen('peco', 'r+') { |io|
io.puts Reline::HISTORY.reverse.uniq
io.gets
}
@buffer_of_lines = code ? code.split("\n") : ['']
@byte_pointer = current_line.bytesize
end
end
# === Rails ===
if defined? Rails::Console
class ActiveRecord::Relation < Object
def pp_sql
# https://www.npmjs.com/package/sql-formatter
system("echo '#{to_sql}' | sql-formatter")
end
end
end