# set up Devel::REPL { use Term::ANSIColor; my @plugins = ( 'ClassRefresh', # refresh before every eval 'Colors', # colorize return value and errors 'Editor', # #e to edit code in vim 'FancyPrompt', # provide an irb-like prompt 'Interrupt', # improve handling of ^C 'LoadClass', # automatically load unloaded classes 'MultiLine::PPI', # allow multiple lines 'Nopaste', # paste session with #nopaste 'OutputCache', # access previous results 'Peek', # Devel::Peek support 'ReadLineHistory', # history saved across sessions 'Time', # time specific commands 'Completion', 'CompletionDriver::Globals', # global variables 'CompletionDriver::INC', # loading new modules 'CompletionDriver::Keywords', # substr, while, etc 'CompletionDriver::LexEnv', # current environment 'CompletionDriver::Methods', # class method completion 'CompletionDriver::Turtles', # turtle command completion ); $_REPL->load_plugin($_) for @plugins; $_REPL->fancy_prompt(sub { my $self = shift; "\ca" . color('blue') . "\cb" . $self->current_package . "\ca" . color('green') . "\cb" . '(0)' . "\ca" . color('reset') . "\cb" . '> ' } ); $_REPL->fancy_continuation_prompt(sub { my $self = shift; "\ca" . color('blue') . "\cb" . $self->current_package . "\ca" . color('yellow') . "\cb" . '(' . $self->line_depth . ')' . "\ca" . color('reset') . "\cb" . '> ' . (' ' x ($self->line_depth * 2)) }); $Devel::REPL::Plugin::Packages::PKG_SAVE = 'main'; } # set up the default environment { package main; use List::Util qw(first max maxstr min minstr reduce shuffle sum); use List::MoreUtils ':all'; use Scalar::Util qw(blessed weaken isweak); use Path::Class; } # load a local config file if it exists { use Cwd (); my $cd = Path::Class::dir(Cwd::getcwd)->absolute->cleanup; my $home = Path::Class::dir(File::HomeDir->my_home)->absolute->cleanup; if ($home->subsumes($cd)) { while ($cd ne $home) { my $proj = $cd->file('.repl.rc'); if (-f $proj) { $Devel::REPL::Script::CURRENT_SCRIPT->apply_script( $proj->stringify, 0, ); last; } $cd = $cd->parent; } } } # stuff that needs to be lexical use 5.010; # would be nice if it was possible to do this conditionally # do this last (and at runtime) so the previous stuff doesn't see it unshift @INC, 'lib'; # vim:filetype=perl: