619ecb5f4fcec9ceb3769f4697fcbb2cbe3f2a7a

Author
Ahmed Azaan <azaan@outlook.com>
Committer
Ahmed Azaan <azaan@outlook.com>
Date

Message

add docker autocomplete plugin

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/docker/README.md b/plugins/docker/README.md
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
  4--- /dev/null
  5+++ b/plugins/docker/README.md
  6diff --git a/plugins/docker/_docker b/plugins/docker/_docker
  7new file mode 100644
  8index 0000000000000000000000000000000000000000..e8d2885c9f757cbdaaaf79fd4a3546e32f4bef80
  9--- /dev/null
 10+++ b/plugins/docker/_docker
 11@@ -0,0 +1,290 @@
 12+#compdef docker
 13+
 14+# Docker autocompletion for oh-my-zsh
 15+# Requires: Docker installed
 16+# Author : Azaan (@aeonazaan)
 17+
 18+
 19+# ----- Helper functions
 20+# Output a selectable list of all running docker containers
 21+__docker_containers() {
 22+    declare -a cont_cmd
 23+    cont_cmd=($(docker ps | awk 'NR>1{print $1":[CON("$1")"$2"("$3")]"}'))
 24+    _describe 'containers' cont_cmd
 25+}
 26+
 27+# output a selectable list of all docker images
 28+__docker_images() {
 29+    declare -a img_cmd
 30+    img_cmd=($(docker images | awk 'NR>1{print $1}'))
 31+    _describe 'images' img_cmd
 32+}
 33+
 34+# ----- Commands
 35+# Seperate function for each command, makes extension easier later
 36+# ---------------------------
 37+__attach() {
 38+    __docker_containers
 39+}
 40+
 41+__build() {
 42+    _arguments \
 43+        '-q=false[Suppress verbose build output]' \
 44+        '-t="[fuck to be applied to the resulting image in case of success]' \
 45+        ' *:files:_files'
 46+}
 47+
 48+__commit() {
 49+    _arguments \
 50+        '-author="[Author]' \
 51+        '-m="[Commit message]' \
 52+        '-run="[Config automatically applied when the image is run.\n]'
 53+    __docker_containers
 54+}
 55+
 56+__diff() {
 57+    __docker_containers
 58+}
 59+
 60+__export() {
 61+   __docker_containers
 62+}
 63+
 64+
 65+__history() {
 66+    __docker_images
 67+}
 68+
 69+__images() {
 70+    _arguments \
 71+        '-a[show all images]' \
 72+        '-notrunc[dont truncate output]' \
 73+        '-q[only show numeric IDs]' \
 74+        '-viz[output graph in graphviz format'
 75+    __docker_images
 76+}
 77+
 78+__import() {
 79+    _arguments '*:files:_files'
 80+}
 81+
 82+__info() {
 83+    # no arguments
 84+}
 85+
 86+__insert() {
 87+    __docker_images
 88+    _arguments '*:files:_files'
 89+}
 90+
 91+__inspect() {
 92+    __docker_images
 93+    __docker_containers
 94+}
 95+
 96+__kill() {
 97+    __docker_containers
 98+}
 99+
100+__login() {
101+    _arguments \
102+        '-e="[email]' \
103+        '-p="[password]' \
104+        '-u="[username]' \
105+}
106+
107+__logs() {
108+    __docker_containers
109+}
110+