summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2022-02-01 15:30:26 +0000
committerJulian Andres Klode <jak@debian.org>2022-02-01 15:30:26 +0000
commitd4a37f071330a6cb6d2ec56ef60ad68ae580f323 (patch)
tree242295dc63ce3c59c82d7116ce598e8a5e00d0aa
parent22b1d03c97960c9dd4b5f4237d08903e57924644 (diff)
parent783138b5bbeb36f4de09ab77bbef7c6f7f7234c6 (diff)
Merge branch 'bash-completion-tweaks-apt-install' into 'main'
Small tweaks for bash-completion after `apt install` See merge request apt-team/apt!216
-rw-r--r--completions/bash/apt17
1 files changed, 8 insertions, 9 deletions
diff --git a/completions/bash/apt b/completions/bash/apt
index 4c3ccbc7e..35716e7a7 100644
--- a/completions/bash/apt
+++ b/completions/bash/apt
@@ -69,7 +69,7 @@ _apt()
# supported options per command
if [[ "$cur" == -* ]]; then
- case $command in
+ case ${command-} in
install|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove)
COMPREPLY=( $( compgen -W '--show-progress
--fix-broken --purge --verbose-versions --auto-remove
@@ -170,7 +170,7 @@ _apt()
fi
# specific command arguments
- if [[ -n $command ]]; then
+ if [[ -v command ]]; then
case $command in
remove|purge|autoremove)
if [[ -f /etc/debian_version ]]; then
@@ -189,10 +189,11 @@ _apt()
return 0
;;
install)
- COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
- 2> /dev/null ) )
- if [[ "$cur" == ./* || "$cur" == /* ]]; then
+ if [[ "$cur" == .* || "$cur" == /* || "$cur" == ~* ]]; then
_filedir "deb"
+ else
+ COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
+ 2> /dev/null ) )
fi
return 0
;;
@@ -217,10 +218,8 @@ _apt()
return 0
;;
esac
- fi
-
- # no command yet, show what commands we have
- if [ "$command" = "" ]; then
+ else
+ # no command yet, show what commands we have
COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) )
fi