Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Split irb config into separate files.

  • Loading branch information...
commit e3d7f1d4ef84770d891783467024cf9c2ee893c4 1 parent 55e6845
@gabebw authored
View
17 irbrc
@@ -3,19 +3,10 @@ require 'pp'
IRB.conf[:AUTO_INDENT] = true
-class Array
- def self.toy
- [1, 2, 3] + %w(a b c)
+def require_rb_files_from(dir)
+ Dir.glob(File.join(dir, '*.rb')) do |file|
+ require file
end
end
-class Hash
- def self.toy
- {
- 1 => 2
- 'a' => 'b',
- 'foo' => 'bar',
- :hello => 'there'
- }
- end
-end
+require_rb_files_from(File.join(ENV['HOME'], '.irbrc.d'))
View
1  irbrc.d/completion.rb
@@ -0,0 +1 @@
+require 'irb/completion'
View
16 irbrc.d/core_extensions.rb
@@ -0,0 +1,16 @@
+class Array
+ def self.toy
+ [1, 2, 3] + %w(a b c)
+ end
+end
+
+class Hash
+ def self.toy
+ {
+ 1 => 2
+ 'a' => 'b',
+ 'foo' => 'bar',
+ :hello => 'there'
+ }
+ end
+end
View
24 irbrc.d/history.rb
@@ -0,0 +1,24 @@
+IRB.conf[:USE_READLINE] = true
+
+module Readline
+ module History
+ LOG = "#{ENV["HOME"]}/.irb-save-history"
+ def self.write_log(line)
+ File.open(LOG, 'ab') {|f| f << "#{line}\n"} unless line == "exit"
+ end
+ end
+
+ alias :old_readline :readline
+ def readline(*args)
+ ln = old_readline(*args)
+ begin
+ History.write_log(ln)
+ rescue
+ end
+ ln
+ end
+end
+
+require 'irb/ext/save-history'
+IRB.conf[:SAVE_HISTORY] = 1000
+IRB.conf[:HISTORY_FILE] = "#{ENV["HOME"]}/.irb-save-history"
Please sign in to comment.
Something went wrong with that request. Please try again.