Skip to content

Commit 1d4f9fa

Browse files
committed
Add bash completion for docker-buildx plugin
Signed-off-by: CrazyMax <[email protected]>
1 parent cb5463a commit 1d4f9fa

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

contrib/completion/bash/docker

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5395,6 +5395,23 @@ _docker_wait() {
53955395
_docker_container_wait
53965396
}
53975397

5398+
BUILDX_PLUGIN_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "buildx"}}{{.Path}}{{end}}{{end}}')
5399+
5400+
_docker_buildx() {
5401+
local completionCommand="__completeNoDesc"
5402+
local resultArray=($BUILDX_PLUGIN_PATH $completionCommand)
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+
53985415
COMPOSE_PLUGIN_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}')
53995416

54005417
_docker_compose() {
@@ -5483,6 +5500,9 @@ _docker() {
54835500

54845501
local known_plugin_commands=()
54855502

5503+
if [ -f "$BUILDX_PLUGIN_PATH" ] ; then
5504+
known_plugin_commands+=("buildx")
5505+
fi
54865506
if [ -f "$COMPOSE_PLUGIN_PATH" ] ; then
54875507
known_plugin_commands+=("compose")
54885508
fi

0 commit comments

Comments
 (0)