summaryrefslogtreecommitdiff
path: root/etc/completion/bash
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-06-04 18:09:11 +0200
committerLudovic Courtès <ludo@gnu.org>2020-06-04 23:26:43 +0200
commit538ca8dd65f0075cc65bcca18ed87f66a789290a (patch)
treeb6e45ce18a472fe86b374ca2cbc103410faecc26 /etc/completion/bash
parentb7bb381ba3740d33652c2a8e7772c17b93b259cc (diff)
bash completion: Complete sub-commands after 'guix time-machine'.
* etc/completion/bash/guix (_guix_complete_subcommand): New function. (_guix_complete): Use it. For "time-machine", call '_guix_complete_subcommand' by default.
Diffstat (limited to 'etc/completion/bash')
-rw-r--r--etc/completion/bash/guix21
1 files changed, 14 insertions, 7 deletions
diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix
index 650cf1d1ce8..df35919eb26 100644
--- a/etc/completion/bash/guix
+++ b/etc/completion/bash/guix
@@ -148,6 +148,17 @@ _guix_complete_pid ()
148 148
149declare _guix_subcommands 149declare _guix_subcommands
150 150
151_guix_complete_subcommand ()
152{
153 if [ -z "$_guix_subcommands" ]
154 then
155 # Cache the list of subcommands to speed things up.
156 _guix_subcommands="$(guix --help 2> /dev/null \
157 | grep '^ ' | cut -c 2-)"
158 fi
159 COMPREPLY=($(compgen -W "$_guix_subcommands" -- "$word_at_point"))
160}
161
151_guix_complete () 162_guix_complete ()
152{ 163{
153 local word_count=${#COMP_WORDS[*]} 164 local word_count=${#COMP_WORDS[*]}
@@ -165,13 +176,7 @@ _guix_complete ()
165 176
166 case $COMP_CWORD in 177 case $COMP_CWORD in
167 1) 178 1)
168 if [ -z "$_guix_subcommands" ] 179 _guix_complete_subcommand
169 then
170 # Cache the list of subcommands to speed things up.
171 _guix_subcommands="$(guix --help 2> /dev/null \
172 | grep '^ ' | cut -c 2-)"
173 fi
174 COMPREPLY=($(compgen -W "$_guix_subcommands" -- "$word_at_point"))
175 ;; 180 ;;
176 *) 181 *)
177 if _guix_is_command "package" 182 if _guix_is_command "package"
@@ -237,6 +242,8 @@ _guix_complete ()
237 if _guix_is_dash_C 242 if _guix_is_dash_C
238 then 243 then
239 _guix_complete_file 244 _guix_complete_file
245 else
246 _guix_complete_subcommand
240 fi 247 fi
241 elif _guix_is_command "container" 248 elif _guix_is_command "container"
242 then 249 then