mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 22:08:16 -05:00
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.
This commit is contained in:
parent
0987a0eba4
commit
8e6989fcaf
1 changed files with 8 additions and 1 deletions
|
@ -72,10 +72,16 @@ _guix_complete_option ()
|
||||||
{
|
{
|
||||||
local command="${COMP_WORDS[$1]}"
|
local command="${COMP_WORDS[$1]}"
|
||||||
local subcommand="${COMP_WORDS[$(($1 + 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
|
then
|
||||||
subcommand=""
|
subcommand=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local options="$(${COMP_WORDS[0]} $command $subcommand --help 2> /dev/null \
|
local options="$(${COMP_WORDS[0]} $command $subcommand --help 2> /dev/null \
|
||||||
| grep '^ \+-' \
|
| grep '^ \+-' \
|
||||||
| sed -e's/^.*--\([a-zA-Z0-9_-]\+\)\(=\?\).*/--\1\2/g')"
|
| sed -e's/^.*--\([a-zA-Z0-9_-]\+\)\(=\?\).*/--\1\2/g')"
|
||||||
|
@ -229,6 +235,7 @@ _guix_complete ()
|
||||||
case $COMP_CWORD in
|
case $COMP_CWORD in
|
||||||
$command_index)
|
$command_index)
|
||||||
_guix_complete_command
|
_guix_complete_command
|
||||||
|
_guix_complete_option 0 "$word_at_point"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ "$command" = "package" ]]
|
if [[ "$command" = "package" ]]
|
||||||
|
|
Loading…
Reference in a new issue