about summary refs log tree commit homepage
path: root/contrib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-03-23 21:45:45 +0000
committerEric Wong <e@80x24.org>2023-03-25 21:03:53 +0000
commit2dd3cec8783700f061a0c9b69e329918a4f5cccd (patch)
tree14eb91e32413f0006706ca0557309b4a37ff6139 /contrib
parent2021c73236b0c7d9f4e6ad90291c35138c9ef75e (diff)
downloadpublic-inbox-2dd3cec8783700f061a0c9b69e329918a4f5cccd.tar.gz
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).
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/lei-completion.bash15
1 files changed, 9 insertions, 6 deletions
diff --git a/contrib/completion/lei-completion.bash b/contrib/completion/lei-completion.bash
index 5c137e68..b86afa2c 100644
--- a/contrib/completion/lei-completion.bash
+++ b/contrib/completion/lei-completion.bash
@@ -1,16 +1,19 @@
-# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # preliminary bash completion support for lei (Local Email Interface)
 # Needs a lot of work, see `lei__complete' in lib/PublicInbox::LEI.pm
 _lei() {
         local wordlist="$(lei _complete ${COMP_WORDS[@]})"
-        case $wordlist in
-        *':'* | *'='* | '//'*) compopt -o nospace ;;
-        *) compopt +o nospace ;; # the default
-        esac
         wordlist="${wordlist//;/\\\\;}" # escape ';' for ';UIDVALIDITY' and such
-        COMPREPLY=($(compgen -W "$wordlist" -- "${COMP_WORDS[COMP_CWORD]}"))
+
+        local word="${COMP_WORDS[COMP_CWORD]}"
+        if test "$word" = ':' && test $COMP_CWORD -ge 1
+        then
+                COMPREPLY=($(compgen -W "$wordlist" --))
+        else
+                COMPREPLY=($(compgen -W "$wordlist" -- "$word"))
+        fi
         return 0
 }
 complete -o default -o bashdefault -F _lei lei