summary refs log tree commit diff
path: root/etc/completion
diff options
context:
space:
mode:
authorTobias Geerinckx-Rice <me@tobias.gr>2021-10-30 16:37:25 +0200
committerTobias Geerinckx-Rice <me@tobias.gr>2021-10-31 00:57:07 +0200
commit8e6989fcaf4a6de00e799777e2a0ccb90fc05e59 (patch)
tree5651535422bf4b9aaac171a3bfd4da821730fc39 /etc/completion
parent0987a0eba4e8220e98e93686a4ad3ef87433fb2f (diff)
downloadguix-8e6989fcaf4a6de00e799777e2a0ccb90fc05e59.tar.gz
bash completion: Complete top-level options.
* etc/completion/bash/guix (_guix_complete_option): Fix operation without a {,sub}command.
(_guix_complete): Call it also when no command is given.
Diffstat (limited to 'etc/completion')
-rw-r--r--etc/completion/bash/guix9
1 files changed, 8 insertions, 1 deletions
diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix
index 5d1ae37f12..6a11e1b23b 100644
--- a/etc/completion/bash/guix
+++ b/etc/completion/bash/guix
@@ -72,10 +72,16 @@ _guix_complete_option ()
 {
     local command="${COMP_WORDS[$1]}"
     local subcommand="${COMP_WORDS[$(($1 + 1))]}"
-    if _guix_is_option "$subcommand"
+
+    if [ $1 -le 1 ]
+    then
+	command=""
+	subcommand=""
+    elif _guix_is_option "$subcommand"
     then
 	subcommand=""
     fi
+
     local options="$(${COMP_WORDS[0]} $command $subcommand --help 2> /dev/null \
                             | grep '^  \+-' \
                             | sed -e's/^.*--\([a-zA-Z0-9_-]\+\)\(=\?\).*/--\1\2/g')"
@@ -229,6 +235,7 @@ _guix_complete ()
     case $COMP_CWORD in
 	$command_index)
 	    _guix_complete_command
+	    _guix_complete_option 0 "$word_at_point"
 	    ;;
 	*)
 	    if [[ "$command" = "package" ]]