[Bps-public-commit] r15103 - in Prophet/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Tue Aug 12 20:58:38 EDT 2008


Author: sartak
Date: Tue Aug 12 20:58:24 2008
New Revision: 15103

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm

Log:
 r69443 at onn:  sartak | 2008-08-12 20:58:03 -0400
 Make shell history persistent


Modified: Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm	Tue Aug 12 20:58:24 2008
@@ -68,6 +68,25 @@
     }
 }
 
+# make the REPL history persistent
+around run => sub {
+    my $orig = shift;
+    my $self = shift;
+
+    my $hist = $ENV{PROPHET_HISTFILE}
+            || (($ENV{HOME} || (getpwuid($<))[7]) . "/.prophetreplhist");
+    my $len = $ENV{PROPHET_HISTLEN} || 100;
+
+    $self->term->stifle_history($len);
+    $self->term->ReadHistory($hist)
+        if -f $hist;
+
+    $self->$orig(@_);
+
+    $self->term->WriteHistory($hist)
+        or warn "Unable to write to shell history file $hist";
+};
+
 __PACKAGE__->meta->make_immutable;
 no Moose;
 



More information about the Bps-public-commit mailing list