aboutsummaryrefslogtreecommitdiff
path: root/completions/bash/podman
diff options
context:
space:
mode:
Diffstat (limited to 'completions/bash/podman')
-rw-r--r--completions/bash/podman31
1 files changed, 30 insertions, 1 deletions
diff --git a/completions/bash/podman b/completions/bash/podman
index dcac09db5..c7171a9cc 100644
--- a/completions/bash/podman
+++ b/completions/bash/podman
@@ -116,13 +116,42 @@ __podman_process_completion_results() {
_filedir -d
fi
else
- __podman_handle_standard_completion_case
+ __podman_handle_completion_types
fi
__podman_handle_special_char "$cur" :
__podman_handle_special_char "$cur" =
}
+__podman_handle_completion_types() {
+ __podman_debug "__podman_handle_completion_types: COMP_TYPE is $COMP_TYPE"
+
+ case $COMP_TYPE in
+ 37|42)
+ # Type: menu-complete/menu-complete-backward and insert-completions
+ # If the user requested inserting one completion at a time, or all
+ # completions at once on the command-line we must remove the descriptions.
+ # https://github.com/spf13/cobra/issues/1508
+ local tab comp
+ tab=$(printf '\t')
+ while IFS='' read -r comp; do
+ # Strip any description
+ comp=${comp%%$tab*}
+ # Only consider the completions that match
+ comp=$(compgen -W "$comp" -- "$cur")
+ if [ -n "$comp" ]; then
+ COMPREPLY+=("$comp")
+ fi
+ done < <(printf "%s\n" "${out[@]}")
+ ;;
+
+ *)
+ # Type: complete (normal completion)
+ __podman_handle_standard_completion_case
+ ;;
+ esac
+}
+
__podman_handle_standard_completion_case() {
local tab comp
tab=$(printf '\t')