3042a1a834645002750e570acd603925547c86e6

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

Update docker completion (#5354)

* Update the docker completion script with the official docker zsh completion script
* Update README

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/docker/README.md b/plugins/docker/README.md
  2index 231a6dcf5d1fc656e02ed0fcc98e606fd8109ce6..1615f75f5fe57e988e404de5ba1e3108ece602cf 100644
  3--- a/plugins/docker/README.md
  4+++ b/plugins/docker/README.md
  5@@ -1,19 +1,5 @@
  6 ## Docker autocomplete plugin
  7 
  8-- Adds autocomplete options for all docker commands.
  9-- Will also show containerIDs and Image names where applicable
 10-
 11-####Shows help for all commands
 12-![General Help](http://i.imgur.com/tUBO9jh.png "Help for all commands")
 13-
 14-
 15-####Shows your downloaded images where applicable
 16-![Images](http://i.imgur.com/R8ZsWO1.png "Images")
 17-
 18-
 19-####Shows your running containers where applicable
 20-![Containers](http://i.imgur.com/WQtbheg.png "Containers")
 21-
 22-
 23-
 24-Maintainer : Ahmed Azaan ([@aeonazaan](https://twitter.com/aeonazaan))
 25+A copy of the completion script from the
 26+[docker](https://github.com/docker/docker/tree/master/contrib/completion/zsh)
 27+git repo.
 28diff --git a/plugins/docker/_docker b/plugins/docker/_docker
 29index a82a31ad3441f78d1b79aca8220728b01fe86ff1..66dfeea9ef50a5a7142cca0ca41a6a0fe8206855 100644
 30--- a/plugins/docker/_docker
 31+++ b/plugins/docker/_docker
 32@@ -1,439 +1,2144 @@
 33-#compdef docker
 34+#compdef docker dockerd
 35+#
 36+# zsh completion for docker (http://docker.com)
 37+#
 38+# version:  0.3.0
 39+# github:   https://github.com/felixr/docker-zsh-completion
 40+#
 41+# contributors:
 42+#   - Felix Riedel
 43+#   - Steve Durrheimer
 44+#   - Vincent Bernat
 45+#
 46+# license:
 47+#
 48+# Copyright (c) 2013, Felix Riedel
 49+# All rights reserved.
 50+#
 51+# Redistribution and use in source and binary forms, with or without
 52+# modification, are permitted provided that the following conditions are met:
 53+#     * Redistributions of source code must retain the above copyright
 54+#       notice, this list of conditions and the following disclaimer.
 55+#     * Redistributions in binary form must reproduce the above copyright
 56+#       notice, this list of conditions and the following disclaimer in the
 57+#       documentation and/or other materials provided with the distribution.
 58+#     * Neither the name of the <organization> nor the
 59+#       names of its contributors may be used to endorse or promote products
 60+#       derived from this software without specific prior written permission.
 61+#
 62+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 63+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 64+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 65+# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 66+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 67+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 68+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 69+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 70+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 71+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 72+#
 73 
 74-# Docker autocompletion for oh-my-zsh
 75-# Requires: Docker installed
 76-# Author: Azaan (@aeonazaan)
 77-# Updates: Bob Maerten (@bobmaerten) for Docker v0.9+
 78-#          Paul van den Berg (@bergvandenp) for Docker v1.3+ 
 79+# Short-option stacking can be enabled with:
 80+#  zstyle ':completion:*:*:docker:*' option-stacking yes
 81+#  zstyle ':completion:*:*:docker-*:*' option-stacking yes
 82+__docker_arguments() {
 83+    if zstyle -t ":completion:${curcontext}:" option-stacking; then
 84+        print -- -s
 85+    fi
 86+}
 87+
 88+__docker_get_containers() {
 89+    [[ $PREFIX = -* ]] && return 1
 90+    integer ret=1
 91+    local kind type line s
 92+    declare -a running stopped lines args names
 93+
 94+    kind=$1; shift
 95+    type=$1; shift
 96+    [[ $kind = (stopped|all) ]] && args=($args -a)
 97+
 98+    lines=(${(f)"$(_call_program commands docker $docker_options ps --format 'table' --no-trunc $args)"})
 99+
100+    # Parse header line to find columns
101+    local i=1 j=1 k header=${lines[1]}
102+    declare -A begin end
103+    while (( j < ${#header} - 1 )); do
104+        i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
105+        j=$(( i + ${${header[$i,-1]}[(i)  ]} - 1 ))
106+        k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
107+        begin[${header[$i,$((j-1))]}]=$i
108+        end[${header[$i,$((j-1))]}]=$k
109+    done
110+    end[${header[$i,$((j-1))]}]=-1 # Last column, should go to the end of the line
111+    lines=(${lines[2,-1]})
112+
113+    # Container ID
114+    if [[ $type = (ids|all) ]]; then
115+        for line in $lines; do
116+            s="${${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}[0,12]}"
117+            s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
118+            s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}"
119+            if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
120+                stopped=($stopped $s)
121+            else
122+                running=($running $s)
123+            fi
124+        done
125+    fi
126+
127+    # Names: we only display the one without slash. All other names
128+    # are generated and may clutter the completion. However, with
129+    # Swarm, all names may be prefixed by the swarm node name.
130+    if [[ $type = (names|all) ]]; then
131+        for line in $lines; do