@@ -1142,6 +1142,29 @@ __docker_complete_user_group() {
11421142 fi
11431143}
11441144
1145+ DOCKER_PLUGINS_PATH=$( docker info --format ' {{range .ClientInfo.Plugins}}{{.Path}}:{{end}}' )
1146+
1147+ __docker_complete_plugin () {
1148+ local path=$1
1149+ local completionCommand=" __completeNoDesc"
1150+ local resultArray=($path $completionCommand )
1151+ for value in " ${words[@]: 2} " ; do
1152+ if [ -z " $value " ]; then
1153+ resultArray+=( " ''" )
1154+ else
1155+ resultArray+=( " $value " )
1156+ fi
1157+ done
1158+ local result=$( eval " ${resultArray[*]} " 2> /dev/null | grep -v ' ^:[0-9]*$' )
1159+
1160+ # if result empty, just use filename completion as fallback
1161+ if [ -z " $result " ]; then
1162+ _filedir
1163+ else
1164+ COMPREPLY=( $( compgen -W " ${result} " -- " ${current-} " ) )
1165+ fi
1166+ }
1167+
11451168_docker_docker () {
11461169 # global options that may appear after the docker command
11471170 local boolean_options="
@@ -5395,23 +5418,6 @@ _docker_wait() {
53955418 _docker_container_wait
53965419}
53975420
5398- COMPOSE_PLUGIN_PATH=$( docker info --format ' {{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}' )
5399-
5400- _docker_compose () {
5401- local completionCommand=" __completeNoDesc"
5402- local resultArray=($COMPOSE_PLUGIN_PATH $completionCommand compose)
5403- for value in " ${words[@]: 2} " ; do
5404- if [ -z " $value " ]; then
5405- resultArray+=( " ''" )
5406- else
5407- resultArray+=( " $value " )
5408- fi
5409- done
5410- local result=$( eval " ${resultArray[*]} " 2> /dev/null | grep -v ' ^:[0-9]*$' )
5411-
5412- COMPREPLY=( $( compgen -W " ${result} " -- " ${current-} " ) )
5413- }
5414-
54155421_docker () {
54165422 local previous_extglob_setting=$( shopt -p extglob)
54175423 shopt -s extglob
@@ -5481,11 +5487,16 @@ _docker() {
54815487 wait
54825488 )
54835489
5490+ # Create completion functions for all registered plugins
54845491 local known_plugin_commands=()
5485-
5486- if [ -f " $COMPOSE_PLUGIN_PATH " ] ; then
5487- known_plugin_commands+=(" compose" )
5488- fi
5492+ local plugin_name=" "
5493+ for plugin_path in ${DOCKER_PLUGINS_PATH//:/ } ; do
5494+ plugin_name=$( basename " $plugin_path " | sed ' s/ *$//' )
5495+ plugin_name=${plugin_name# docker-}
5496+ plugin_name=${plugin_name%% .* }
5497+ eval " _docker_${plugin_name} () { __docker_complete_plugin \" ${plugin_path} \" ; }"
5498+ known_plugin_commands+=(${plugin_name} )
5499+ done
54895500
54905501 local experimental_server_commands=(
54915502 checkpoint
0 commit comments