initial add
This commit is contained in:
commit
1e414f35c9
6 changed files with 146 additions and 0 deletions
38
pshell.pl
Executable file
38
pshell.pl
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use lib 'lib';
|
||||
use History::SQLite;
|
||||
use Term::ReadLine;
|
||||
|
||||
# Initialize command history
|
||||
my $history = History::SQLite->new(
|
||||
db_path => 'pshell_history.db'
|
||||
);
|
||||
|
||||
print "Perl Shell (pshell) - Type 'exit' to quit\n";
|
||||
|
||||
my $term = Term::ReadLine->new('pshell');
|
||||
$term->ornaments(0);
|
||||
|
||||
# Load previous history
|
||||
my @history = $history->get_all;
|
||||
$term->addhistory($_) for @history;
|
||||
|
||||
while (1) {
|
||||
my $prompt = "pshell> ";
|
||||
my $command = $term->readline($prompt);
|
||||
|
||||
last unless defined $command;
|
||||
chomp $command;
|
||||
last if $command =~ /^exit$/i;
|
||||
|
||||
# Skip empty commands
|
||||
next unless length $command;
|
||||
|
||||
# Save command to history
|
||||
$history->add($command);
|
||||
$term->addhistory($command);
|
||||
|
||||
# Execute command
|
||||
system($command);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue