Add more types to bash completion of docker inspect

Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit 1076f0882b)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
Harald Albers 2016-11-29 09:02:16 -08:00 committed by Victor Vieux
parent d55b0802cf
commit 7c081219ac

View file

@ -123,7 +123,7 @@ __docker_complete_container_ids() {
COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") )
}
__docker_complete_images() {
__docker_images() {
local images_args=""
case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in
@ -152,8 +152,11 @@ __docker_complete_images() {
;;
esac
local images=$(__docker_q images $images_args | awk "$awk_script")
COMPREPLY=( $(compgen -W "$images" -- "$cur") )
__docker_q images $images_args | awk "$awk_script" | grep -v '<none>$'
}
__docker_complete_images() {
COMPREPLY=( $(compgen -W "$(__docker_images)" -- "$cur") )
__ltrim_colon_completions "$cur"
}
@ -168,13 +171,6 @@ __docker_complete_image_repos_and_tags() {
__ltrim_colon_completions "$cur"
}
__docker_complete_containers_and_images() {
__docker_complete_containers_all
local containers=( "${COMPREPLY[@]}" )
__docker_complete_images
COMPREPLY+=( "${containers[@]}" )
}
# __docker_networks returns a list of all networks. Additional options to
# `docker network ls` may be specified in order to filter the list, e.g.
# `__docker_networks --filter type=custom`
@ -2269,7 +2265,7 @@ _docker_inspect() {
;;
--type)
if [ -z "$preselected_type" ] ; then
COMPREPLY=( $( compgen -W "image container" -- "$cur" ) )
COMPREPLY=( $( compgen -W "container image network node service volume" -- "$cur" ) )
return
fi
;;
@ -2286,7 +2282,14 @@ _docker_inspect() {
*)
case "$type" in
'')
__docker_complete_containers_and_images
COMPREPLY=( $( compgen -W "
$(__docker_containers --all)
$(__docker_images)
$(__docker_networks)
$(__docker_nodes)
$(__docker_services)
$(__docker_volumes)
" -- "$cur" ) )
;;
container)
__docker_complete_containers_all
@ -2294,6 +2297,18 @@ _docker_inspect() {
image)
__docker_complete_images
;;
network)
__docker_complete_networks
;;
node)
__docker_complete_nodes
;;
service)
__docker_complete_services
;;
volume)
__docker_complete_volumes
;;
esac
esac
}