-
Notifications
You must be signed in to change notification settings - Fork 2
/
.rdebugrc
31 lines (28 loc) · 1.33 KB
/
.rdebugrc
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
set autoeval
set autolist
set history save
set history size 10000
## Ruby ruby-debug sucks:
## - docs say you can set the history file, but you can't.
## - almost everything's done with basic objects and singleton methods, and it's a bitch to hack anything.
## - the history is read when the LocalInterface is initialized (so you have to manually clear and re-add).
##
## Ruby's readline lib on OSX sucks:
## - you can't clear the history in one call (so you have to pop)
## - it loses the first entry on every load/save (so you have to leave one in)
##
## So, because *THIS* doesn't work:
##
##set history filename "#{ENV['HOME']}/.ruby_history"
##
## We have to do *THIS* bullshit:
eval @init or MY_HISTORY = "#{ENV['HOME']}/.ruby_history"
eval @init or (Readline::HISTORY.pop while Readline::HISTORY.length > 1)
eval @init or File.read(MY_HISTORY).split($/).each{ |l| Readline::HISTORY << l }
eval @init or ObjectSpace.each_object(Debugger::LocalInterface) { |i| i.histfile = MY_HISTORY }
eval @init or @init = true
## Note: The @init hack is necessary in order to prevent unsaved history from
## being lost in between debugger "invocations". This is because this file is
## loaded everytime a debugger session is entered (e.g. re-entering a debugger
## after (c)ontinuing from a previous one), yet (c)ontinuing doesn't trigger a
## HISTORY save.