diff options
author | Julian Andres Klode <jak@debian.org> | 2022-02-22 16:35:02 +0000 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2022-02-22 16:35:02 +0000 |
commit | 647847769adca37a0b036c64cc0fad06b49bd99c (patch) | |
tree | f85b18b4f342ecef9c3a7828e79b737fe752f304 /completions/bash | |
parent | 3834826b1628f9a7d5540c69aeb7d311faaf02c2 (diff) | |
parent | 19ffda1489858d132551a267fccdf7ab03b5e103 (diff) |
Merge branch 'dont-bash-complete-pkgs-before-cmd' into 'main'
Don’t bash-complete package names before the command word
See merge request apt-team/apt!221
Diffstat (limited to 'completions/bash')
-rw-r--r-- | completions/bash/apt | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/completions/bash/apt b/completions/bash/apt index b615c578f..59a8eaa94 100644 --- a/completions/bash/apt +++ b/completions/bash/apt @@ -52,7 +52,7 @@ _apt() "policy") local command i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for (( i=1; i < ${#words[@]}; i++ )); do if [[ " ${COMMANDS[*]} " == *" ${words[i]} "* ]]; then command=${words[i]} break @@ -67,8 +67,9 @@ _apt() ;; esac - # supported options per command - if [[ "$cur" == -* ]]; then + # When the cursor (cword) is before the command word (i), only suggest + # options but not package or file names: + if [[ $cur == -* || ( -v command && $cword -le $i ) ]]; then case ${command-} in install|reinstall|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove|autopurge) COMPREPLY=( $( compgen -W '--show-progress @@ -167,6 +168,8 @@ _apt() return 0 ;; esac + + return fi # specific command arguments |