From 4d3122b2a7fe6024b2b18b42ad09ae013f1d5574 Mon Sep 17 00:00:00 2001 From: Dmytro Aleksandrov Date: Mon, 20 Oct 2014 13:29:40 +0300 Subject: [PATCH 1/2] Added docker exec completion, introduced in docker 1.3 --- plugins/docker/_docker | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 28568a6e5..83a12b801 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -61,6 +61,14 @@ __events() { '--since=[Show previously created events and then stream.]' } +__exec() { + _arguments \ + '-d[Detached mode: run command in the background]' \ + '-i[Keep STDIN open even if not attached]' \ + '-t[Allocate a pseudo-TTY]' + __docker_containers +} + __export() { __docker_containers } @@ -249,6 +257,7 @@ _1st_arguments=( "cp":"Copy files/folders from the containers filesystem to the host path" "diff":"Inspect changes on a container's filesystem" "events":"Get real time events from the server" + "exec":"Run a command in an existing container" "export":"Stream the contents of a container as a tar archive" "history":"Show the history of an image" "images":"List images" @@ -299,6 +308,8 @@ case "$words[1]" in __diff ;; events) __events ;; + exec) + __exec ;; export) __export ;; history) From 82aab6bf513de2690d44891eba1354fa07eb40ca Mon Sep 17 00:00:00 2001 From: Dmytro Aleksandrov Date: Mon, 20 Oct 2014 13:32:00 +0300 Subject: [PATCH 2/2] Extended containers list with quited containers for __rm command --- plugins/docker/_docker | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 83a12b801..b9d0f5453 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -14,6 +14,13 @@ __docker_containers() { _describe 'containers' cont_cmd } +# Output a list of all containers (both running and stopped) +__docker_containers_all() { + declare -a cont_cmd + cont_cmd=($(docker ps -a | awk 'NR>1{print $1":[CON("$1")"$2"("$3")]"}')) + _describe 'containers' cont_cmd +} + # output a selectable list of all docker images __docker_images() { declare -a img_cmd @@ -169,7 +176,7 @@ __rm() { '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \ '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \ '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]' - __docker_containers + __docker_containers_all } __rmi() {