From ebdb229ce68979a18dae5c0922620b860c56b22f Mon Sep 17 00:00:00 2001 From: Ben Blank Date: Tue, 17 Dec 2024 04:42:20 -0800 Subject: [PATCH] fix(completions): Address two Bash completion bugs (#1770) Co-authored-by: Trevor Brown --- completions/asdf.bash | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/completions/asdf.bash b/completions/asdf.bash index f828e9db..f3ad87ff 100644 --- a/completions/asdf.bash +++ b/completions/asdf.bash @@ -39,7 +39,7 @@ _asdf() { COMPREPLY=($(compgen -W "$available_plugins" -- "$cur")) ;; install | list | list-all | help) - if [[ "$plugins" == *"$prev"* ]]; then + if [[ " $plugins " == *" $prev "* ]]; then local versions versions=$(asdf list-all "$prev" 2>/dev/null) # shellcheck disable=SC2207 @@ -54,9 +54,10 @@ _asdf() { COMPREPLY=($(compgen -W "--head" -- "$cur")) ;; uninstall | where | reshim) - if [[ "$plugins" == *"$prev"* ]]; then + if [[ " $plugins " == *" $prev "* ]]; then local versions - versions=$(asdf list "$prev" 2>/dev/null) + # The first two columns are either blank or contain the "current" marker. + versions=$(asdf list "$prev" 2>/dev/null | colrm 1 2) # shellcheck disable=SC2207 COMPREPLY=($(compgen -W "$versions" -- "$cur")) else @@ -65,9 +66,10 @@ _asdf() { fi ;; local | global | shell) - if [[ "$plugins" == *"$prev"* ]]; then + if [[ " $plugins " == *" $prev "* ]]; then local versions - versions=$(asdf list "$prev" 2>/dev/null) + # The first two columns are either blank or contain the "current" marker. + versions=$(asdf list "$prev" 2>/dev/null | colrm 1 2) versions+=" system" # shellcheck disable=SC2207 COMPREPLY=($(compgen -W "$versions" -- "$cur"))