summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörn-Thorben Hinz <11910-jth@users.noreply.salsa.debian.org>2022-02-03 23:23:27 +0100
committerJörn-Thorben Hinz <11910-jth@users.noreply.salsa.debian.org>2022-02-04 17:26:04 +0100
commit19ffda1489858d132551a267fccdf7ab03b5e103 (patch)
treecc3a01dbe8a05043370c82307475828c104fc153
parent5599b21c5fa6ceffa1be24b2974a4d402d06bf7a (diff)
Don’t bash-complete package names before the command word
Previously, package names would get suggested at the cursor position `_` for a command line like this: ``` ~# apt _ install git vim ```
-rw-r--r--completions/bash/apt7
1 files changed, 5 insertions, 2 deletions
diff --git a/completions/bash/apt b/completions/bash/apt
index 94ad974b1..f60f9e97c 100644
--- a/completions/bash/apt
+++ b/completions/bash/apt
@@ -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|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove)
COMPREPLY=( $( compgen -W '--show-progress
@@ -167,6 +168,8 @@ _apt()
return 0
;;
esac
+
+ return
fi
# specific command arguments