Reputation: 138
Using this code:
#!/usr/bin/env perl
use warnings;
use strict;
package Testsh;
use base qw(Term::Shell);
my @actions = qw/ a b c d e f g h /;
sub comp_cd {
my ( $self, $action ) = @_;
$self->completions( $action, \@actions);
}
sub run_cd {
my ( $self, $action ) = @_;
$self->prompt( "$action~> ");
}
package main;
my $shell = Testsh->new;
$shell->cmdloop;
When I start the shell, and press tab twice, I get three options: cd, exit help.
If I cd to one of the actions, then the prompt gets changed to the action name, but I no longer am capable of using tab completion. Why is this?
Upvotes: 0
Views: 54
Reputation: 241978
As documented in The Term:Shell API, you can specify completions to prompt
as the third argument:
$self->prompt( "$action~> ", '', [ glob '*' ]);
Upvotes: 3