From 2dd3cec8783700f061a0c9b69e329918a4f5cccd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 23 Mar 2023 21:45:45 +0000 Subject: lei: improve bash completion involving colons This fixes completions of labels (`+L:' for `lei import' and `L:' for `lei q') so they can appear anywhere in the command-line. I mainly wanted this for `lei import $URL +L:label', but this also fixes `lei forget-external' completions for URLs (which involve colons). --- lib/PublicInbox/LeiForgetExternal.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/PublicInbox/LeiForgetExternal.pm') diff --git a/lib/PublicInbox/LeiForgetExternal.pm b/lib/PublicInbox/LeiForgetExternal.pm index 07f0ac80..39bfc60b 100644 --- a/lib/PublicInbox/LeiForgetExternal.pm +++ b/lib/PublicInbox/LeiForgetExternal.pm @@ -32,14 +32,10 @@ sub lei_forget_external { sub _complete_forget_external { my ($lei, @argv) = @_; my $cfg = $lei->_lei_cfg or return (); - my ($cur, $re, $match_cb) = $lei->complete_url_prepare(\@argv); - # FIXME: bash completion off "http:" or "https:" when the last - # character is a colon doesn't work properly even if we're - # returning "//$HTTP_HOST/$PATH_INFO/", not sure why, could - # be a bash issue. + my ($pfx, $cur, $match_cb) = $lei->complete_url_prepare(\@argv); map { $match_cb->(substr($_, length('external.'))); - } grep(/\Aexternal\.$re\Q$cur/, @{$cfg->{-section_order}}); + } grep(/\Aexternal\.\Q$pfx$cur/, @{$cfg->{-section_order}}); } 1; -- cgit v1.2.3-24-ge0c7