From 27f2b96b70b0a231ec56c45e9680381f1f14add2 Mon Sep 17 00:00:00 2001 From: Steve Durrheimer Date: Sat, 11 Jun 2016 14:14:02 +0200 Subject: [PATCH] Add zsh completion for 'docker {create,run} --pid' values Signed-off-by: Steve Durrheimer --- contrib/completion/zsh/_docker | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index 9ebe2cc4d2..e317777825 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -274,6 +274,31 @@ __docker_complete_detach_keys() { _describe -t detach_keys-ctrl "'ctrl-' + 'a-z @ [ \\\\ ] ^ _'" ctrl_keys -qS "," && ret=0 } +__docker_complete_pid() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + local -a opts vopts + + opts=('host') + vopts=('container') + + if compset -P '*:'; then + case "${${words[-1]%:*}#*=}" in + (container) + __docker_runningcontainers && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + _describe -t pid-value-opts "PID Options with value" vopts -qS ":" && ret=0 + _describe -t pid-opts "PID Options" opts && ret=0 + fi + + return ret +} + __docker_complete_ps_filters() { [[ $PREFIX = -* ]] && return 1 integer ret=1 @@ -750,7 +775,7 @@ __docker_subcommand() { "($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]" "($help -P --publish-all)"{-P,--publish-all}"[Publish all exposed ports]" "($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports" - "($help)--pid=[PID namespace to use]:PID namespace: " + "($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid" "($help)--privileged[Give extended privileges to this container]" "($help)--read-only[Mount the container's root filesystem as read only]" "($help)*--security-opt=[Security options]:security option: "