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
|
#!/usr/bin/env perl6
use v6;
use Readline;
my $readline = Readline.new;
my %history;
while my $response = $readline.readline( "prompt here (<cr> to exit)> " ) {
if $response ~~ /ding/ {
$readline.ding;
}
elsif $response ~~ /clear/ {
$readline.clear-history;
}
elsif $response ~~ /is \s+ stifled/ {
say $readline.history-is-stifled ?? "Yes" !! "No";
}
elsif $response ~~ /unstifle/ {
$readline.unstifle-history;
}
elsif $response ~~ /stifle/ {
$readline.stifle-history( 1 );
}
elsif $response ~~ /\S/ {
unless %history{$response} {
$readline.add-history( $response );
%history{$response} = 1;
}
}
say "[$response]";
}
|