-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathirbrc
70 lines (61 loc) · 1.33 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
# .irbrc
# vim: set syntax=ruby foldmethod=marker :
require 'irb/completion'
require 'irb/ext/save-history'
require 'fileutils'
require 'pp'
%w[
rubygems
ap
interactive_editor
].each do |gem|
begin
require gem
rescue LoadError
end
end
ARGV.concat [ "--readline",
"--prompt-mode",
"simple" ]
# 1000 entries in the list
IRB.conf[:SAVE_HISTORY] = 1000
# Store results in home directory with specified file name
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
IRB.conf[:PROMPT_MODE] = :SIMPLE
# Copy/Paste stuff for OS X {{{1
def copy(str)
IO.popen('pbcopy', 'w') { |f| f << str.to_s }
end
def copy_history
history = Readline::HISTORY.entries
index = history.rindex("exit") || -1
content = history[(index+1)..-2].join("\n")
puts content
copy content
end
def paste
`pbpaste`
end
# This extension adds a UNIX-style pipe to strings {{{1
#
# Synopsis:
#
# >> puts "UtilityBelt is better than alfalfa" | "cowsay"
# ____________________________________
# < UtilityBelt is better than alfalfa >
# ------------------------------------
# \ ^__^
# \ (oo)\_______
# (__)\ )\/\
# ||----w |
# || ||
# => nil
class String
def |(cmd)
IO.popen(cmd.to_s, 'r+') do |pipe|
pipe.write(self)
pipe.close_write
pipe.read
end
end
end