forを使用してrlwrap
複数の単語のオートコンプリートを取得するにはtclsh
?
例:またはのように表示したいサブコマンドを入力file
<space>
してからタップします。<tab>
<tab>
file
exists
isdirectory
isfile
完成ファイルに追加(例:空白エスケープ)を試しましたが、file\ isfile
役に立ちませんでした。ただisfile
別のオートコンプリートコマンドとして表示されます。
私はフィルタを使用して複数の単語のオートコンプリートを実行できると思いますが、参照するrlwrap
明確な例はありません。/usr/share/rlwarp/filters/
ベストアンサー1
少なくともフィルタディレクトリtclsh_filter
の例があります(そこにあることrlwrap
を確認してください)。chmod +x
#!/usr/bin/env perl
use strict;
use warnings;
use lib $ENV{RLWRAP_FILTERDIR};
use RlwrapFilter;
# log to some other terminal, so rlwrap terminal not cluttered up
# by any debug output - FIXME
my $DEBUG_TERMINAL = '/dev/pts/2';
open my $logfh, '>', $DEBUG_TERMINAL or die "aaaaaarrgh: $!\n";
my $filter = RlwrapFilter->new;
$filter->completion_handler(\&completion);
$filter->run;
sub completion {
my ($input, $prefix, @completions) = @_;
print $logfh "I,$input, P,$prefix, C,@completions\n";
# more complicated would be to use a lex-like scanner or Parser::MGC
# instead of this dumb regex against the input line, and even more
# complicated would be to return "exists" if the user has typed
# "file e" and is mashing tab, but that's more work
if ($input =~ m/file\s+$/) {
@completions = qw/exists isdirectory isfile/;
}
return @completions;
}
次に実行します。rlwrap -z tclsh_filter tclsh