a93bb4e695b773db6c9fc4b6dac46809f14d7e89

Author
kenleytomlin <kenleytomlin@gmail.com>
Committer
kenleytomlin <kenleytomlin@gmail.com>
Date

Message

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

Diff

This diff is truncated to protect this page.

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