Add more types to bash completion of `docker inspect`

Signed-off-by: Harald Albers <github@albersweb.de>
This commit is contained in:
Harald Albers 2016-11-29 09:02:16 -08:00 committed by Tibor Vass
parent bfa5aeec42
commit c310a10969
1 changed files with 27 additions and 12 deletions

View File

@ -123,7 +123,7 @@ __docker_complete_container_ids() {
COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") )
} }
__docker_complete_images() { __docker_images() {
local images_args="" local images_args=""
case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in
@ -152,8 +152,11 @@ __docker_complete_images() {
;; ;;
esac esac
local images=$(__docker_q images $images_args | awk "$awk_script") __docker_q images $images_args | awk "$awk_script" | grep -v '<none>$'
COMPREPLY=( $(compgen -W "$images" -- "$cur") ) }
__docker_complete_images() {
COMPREPLY=( $(compgen -W "$(__docker_images)" -- "$cur") )
__ltrim_colon_completions "$cur" __ltrim_colon_completions "$cur"
} }
@ -168,13 +171,6 @@ __docker_complete_image_repos_and_tags() {
__ltrim_colon_completions "$cur" __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_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 network ls` may be specified in order to filter the list, e.g.
# `__docker_networks --filter type=custom` # `__docker_networks --filter type=custom`
@ -2268,7 +2264,7 @@ _docker_inspect() {
;; ;;
--type) --type)
if [ -z "$preselected_type" ] ; then if [ -z "$preselected_type" ] ; then
COMPREPLY=( $( compgen -W "image container" -- "$cur" ) ) COMPREPLY=( $( compgen -W "container image network node service volume" -- "$cur" ) )
return return
fi fi
;; ;;
@ -2285,7 +2281,14 @@ _docker_inspect() {
*) *)
case "$type" in 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) container)
__docker_complete_containers_all __docker_complete_containers_all
@ -2293,6 +2296,18 @@ _docker_inspect() {
image) image)
__docker_complete_images __docker_complete_images
;; ;;
network)
__docker_complete_networks
;;
node)
__docker_complete_nodes
;;
service)
__docker_complete_services
;;
volume)
__docker_complete_volumes
;;
esac esac
esac esac
} }