1 # First cut at using the readline history directly rather than reimplementing
2 # it. It does save history but it's a little crappy; still playing with it ;)
4 # epitaph, 22nd April 2007
6 package Devel::REPL::Plugin::ReadLineHistory;
8 use Devel::REPL::Plugin;
10 my $hist_file=$ENV{PERLREPL_HISTFILE} ||
11 (($ENV{HOME} || (getpwuid($<))[7]) . "/.perlreplhist");
12 # HISTLEN should probably be in a config file to stop people accidentally
13 # truncating their history if they start the program and forget to set
15 my $hist_len=$ENV{PERLREPL_HISTLEN} || 100;
20 $self->term->stifle_history($hist_len);
21 -f($hist_file) && $self->term->ReadHistory($hist_file);
22 $self->term->Attribs->{do_expand}=1;
24 $self->term->WriteHistory($hist_file) ||
25 $self->print("warning: failed to write history file $hist_file");
34 Devel::REPL::Plugin::ReadLineHistory - Integrate history with the facilities provided by L<Term::ReadLine>