140034605edd0f72c548685d39e49687a44c1b23

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #3825 from kennedyoliveira/master

Some fixes for Docker plugin

Diff

 1diff --git a/plugins/docker/_docker b/plugins/docker/_docker
 2index aadc9c61dd2a165629d03aad564eb1568d5ff435..fd459a0cac85e2a12d2fcbeaf4a0d11843dea59b 100644
 3--- a/plugins/docker/_docker
 4+++ b/plugins/docker/_docker
 5@@ -12,7 +12,16 @@
 6 __docker_containers() {
 7     declare -a cont_cmd
 8     cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
 9-    _describe 'containers' cont_cmd
10+    if [[  'X$cont_cmd' != 'X' ]]
11+        _describe 'containers' cont_cmd
12+}
13+
14+# Output a selectable list of all containers, even not running
15+__docker_all_containers() {
16+    declare -a cont_cmd
17+    cont_cmd=($(docker ps -a | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
18+    if [[  'X$cont_cmd' != 'X' ]]
19+        _describe 'containers' cont_cmd
20 }
21 
22 # output a selectable list of all docker images
23@@ -57,7 +66,7 @@ __diff() {
24     __docker_containers
25 }
26 
27-__events() {
28+__events() {    
29     _arguments \
30         '--since=[Show previously created events and then stream.]'
31 }
32@@ -98,10 +107,12 @@ __insert() {
33 
34 __inspect() {
35     __docker_images
36-    __docker_containers
37+    __docker_all_containers
38 }
39 
40 __kill() {
41+    _arguments \
42+        '(-s,--signal=)'{-s,--signal=}'[KILL Signal]'
43     __docker_containers
44 }
45 
46@@ -162,7 +173,7 @@ __rm() {
47         '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \
48         '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \
49         '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]'
50-    __docker_containers
51+    __docker_all_containers
52 }
53 
54 __rmi() {
55@@ -216,7 +227,7 @@ __start() {
56     _arguments \
57         '(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \
58         '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s stdin]'
59-    __docker_containers
60+    __docker_all_containers
61 }
62 
63 __stats() {