Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split irb config into separate files.
Based on code from @joshuaclayton: https://github.com/joshuaclayton/dotfiles/tree/master/irbrc.d
- Loading branch information
Gabe Berke-Williams
committed
Aug 22, 2012
1 parent
55e6845
commit e3d7f1d
Showing
4 changed files
with
45 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'irb/completion' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |