From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id BA8491F9FD; Thu, 25 Feb 2021 10:33:39 +0000 (UTC) Date: Thu, 25 Feb 2021 10:33:39 +0000 From: Eric Wong To: meta@public-inbox.org Subject: better "compopt -o nospace" ideas? [was: lei: completion: bash: generalize nospace usage] Message-ID: <20210225103339.GA12705@dcvr> References: <20210218122709.18097-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210218122709.18097-1-e@80x24.org> List-Id: Eric Wong wrote: > We'll be completing more options with ':', '//' and '=' in the > future, so make it easier to disable trailing spaces on > completions. > +++ b/contrib/completion/lei-completion.bash > @@ -4,14 +4,12 @@ > # preliminary bash completion support for lei (Local Email Interface) > # Needs a lot of work, see `lei__complete' in lib/PublicInbox::LEI.pm > _lei() { > - case ${COMP_WORDS[@]} in > - *' add-external h'* | *' --mirror h'*) > - compopt -o nospace > - ;; > + local wordlist="$(lei _complete ${COMP_WORDS[@]})" > + case $wordlist in > + *':'* | *'='* | '//'*) compopt -o nospace ;; While this is nicer than before, I'm still wondering if there's a better way for lei to communicate "-o nospace" to bash... (or similar options for other shells) Thanks in advance for any ideas you might provide. > *) compopt +o nospace ;; # the default > esac > - COMPREPLY=($(compgen -W "$(lei _complete ${COMP_WORDS[@]})" \ > - -- "${COMP_WORDS[COMP_CWORD]}")) > + COMPREPLY=($(compgen -W "$wordlist" -- "${COMP_WORDS[COMP_CWORD]}")) > return 0 > } > complete -o default -o bashdefault -F _lei lei