From: Eric Wong Date: Thu, 18 Feb 2021 12:27:09 +0000 (+0600) Subject: lei: completion: bash: generalize nospace usage X-Git-Tag: v1.7.0~1112 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=a2415fec470dad7d9848b55af7c156f96dde13e5 lei: completion: bash: generalize nospace usage We'll be completing more options with ':', '//' and '=' in the future, so make it easier to disable trailing spaces on completions. --- diff --git a/contrib/completion/lei-completion.bash b/contrib/completion/lei-completion.bash index 619805fb..2c28d44a 100644 --- a/contrib/completion/lei-completion.bash +++ 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 ;; *) 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