Prevent faulty autocomplete in zsh for docker rmi

Skip autocompletion when there are no docker images available

Signed-off-by: Ruben Sainiuc <ruben.sainiuc@gmail.com>
This commit is contained in:
Ruben Sainiuc 2016-10-14 10:11:15 +03:00
commit 5c664bba80

View file

@ -151,6 +151,10 @@ __docker_complete_info_plugins() {
__docker_images() { __docker_images() {
[[ $PREFIX = -* ]] && return 1 [[ $PREFIX = -* ]] && return 1
# Prevent autocomplete when there are no images
[[ $(_call_program commands docker $docker_options images --format "{{.ID}}") ]] || return 1
integer ret=1 integer ret=1
declare -a images declare -a images
images=(${${${(f)"$(_call_program commands docker $docker_options images)"}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}}) images=(${${${(f)"$(_call_program commands docker $docker_options images)"}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}})