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.
This commit is contained in:
parent
b7bb381ba3
commit
538ca8dd65
1 changed files with 14 additions and 7 deletions
|
@ -148,6 +148,17 @@ _guix_complete_pid ()
|
||||||
|
|
||||||
declare _guix_subcommands
|
declare _guix_subcommands
|
||||||
|
|
||||||
|
_guix_complete_subcommand ()
|
||||||
|
{
|
||||||
|
if [ -z "$_guix_subcommands" ]
|
||||||
|
then
|
||||||
|
# Cache the list of subcommands to speed things up.
|
||||||
|
_guix_subcommands="$(guix --help 2> /dev/null \
|
||||||
|
| grep '^ ' | cut -c 2-)"
|
||||||
|
fi
|
||||||
|
COMPREPLY=($(compgen -W "$_guix_subcommands" -- "$word_at_point"))
|
||||||
|
}
|
||||||
|
|
||||||
_guix_complete ()
|
_guix_complete ()
|
||||||
{
|
{
|
||||||
local word_count=${#COMP_WORDS[*]}
|
local word_count=${#COMP_WORDS[*]}
|
||||||
|
@ -165,13 +176,7 @@ _guix_complete ()
|
||||||
|
|
||||||
case $COMP_CWORD in
|
case $COMP_CWORD in
|
||||||
1)
|
1)
|
||||||
if [ -z "$_guix_subcommands" ]
|
_guix_complete_subcommand
|
||||||
then
|
|
||||||
# Cache the list of subcommands to speed things up.
|
|
||||||
_guix_subcommands="$(guix --help 2> /dev/null \
|
|
||||||
| grep '^ ' | cut -c 2-)"
|
|
||||||
fi
|
|
||||||
COMPREPLY=($(compgen -W "$_guix_subcommands" -- "$word_at_point"))
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if _guix_is_command "package"
|
if _guix_is_command "package"
|
||||||
|
@ -237,6 +242,8 @@ _guix_complete ()
|
||||||
if _guix_is_dash_C
|
if _guix_is_dash_C
|
||||||
then
|
then
|
||||||
_guix_complete_file
|
_guix_complete_file
|
||||||
|
else
|
||||||
|
_guix_complete_subcommand
|
||||||
fi
|
fi
|
||||||
elif _guix_is_command "container"
|
elif _guix_is_command "container"
|
||||||
then
|
then
|
||||||
|
|
Reference in a new issue