Commit 3de415e6521cb00efe238793a158c0dda148a748

Authored by mj
1 parent 9f5c61b703
Exists in master and in 2 other branches 02-merge, dev

Squashed 'repos/robbyrussell/oh-my-zsh/' changes from 75b9030..1400346

1400346 Merge pull request #3825 from kennedyoliveira/master
cabb8f7 Merge pull request #3814 from willmendesneto/frontend-search-add-autocomplete
2dbf995 Fixing some issues where show repeated weird values, and fixed commands that need the container autocomplete without being running, like start, now it autocompletes showing all the containers so you can start without knowing the right name
590d393 Add autocomplete for frontend-search
ff4663a Merge pull request #3802 from willmendesneto/patch-1
05f2ad3 fix stackoverflow url in search
b4729d3 Merge pull request #3792 from willmendesneto/frontend-search-add-new-repositories
eea77b7 Add stackoverflow link

git-subtree-dir: repos/robbyrussell/oh-my-zsh
git-subtree-split: 140034605edd0f72c548685d39e49687a44c1b23

Showing 4 changed files with 160 additions and 15 deletions Inline Diff

plugins/docker/_docker
1 #compdef docker 1 #compdef docker
2 2
3 # Docker autocompletion for oh-my-zsh 3 # Docker autocompletion for oh-my-zsh
4 # Requires: Docker installed 4 # Requires: Docker installed
5 # Author: Azaan (@aeonazaan) 5 # Author: Azaan (@aeonazaan)
6 # Updates: Bob Maerten (@bobmaerten) for Docker v0.9+ 6 # Updates: Bob Maerten (@bobmaerten) for Docker v0.9+
7 # Paul van den Berg (@bergvandenp) for Docker v1.3+ 7 # Paul van den Berg (@bergvandenp) for Docker v1.3+
8 8
9 9
10 # ----- Helper functions 10 # ----- Helper functions
11 # Output a selectable list of all running docker containers 11 # Output a selectable list of all running docker containers
12 __docker_containers() { 12 __docker_containers() {
13 declare -a cont_cmd 13 declare -a cont_cmd
14 cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}')) 14 cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
15 _describe 'containers' cont_cmd 15 if [[ 'X$cont_cmd' != 'X' ]]
16 _describe 'containers' cont_cmd
17 }
18
19 # Output a selectable list of all containers, even not running
20 __docker_all_containers() {
21 declare -a cont_cmd
22 cont_cmd=($(docker ps -a | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
23 if [[ 'X$cont_cmd' != 'X' ]]
24 _describe 'containers' cont_cmd
16 } 25 }
17 26
18 # output a selectable list of all docker images 27 # output a selectable list of all docker images
19 __docker_images() { 28 __docker_images() {
20 declare -a img_cmd 29 declare -a img_cmd
21 img_cmd=($(docker images | awk 'NR>1{print $1}')) 30 img_cmd=($(docker images | awk 'NR>1{print $1}'))
22 _describe 'images' img_cmd 31 _describe 'images' img_cmd
23 } 32 }
24 33
25 # ----- Commands 34 # ----- Commands
26 # Seperate function for each command, makes extension easier later 35 # Seperate function for each command, makes extension easier later
27 # --------------------------- 36 # ---------------------------
28 __attach() { 37 __attach() {
29 _arguments \ 38 _arguments \
30 '--no-stdin[Do not attach stdin]' \ 39 '--no-stdin[Do not attach stdin]' \
31 '--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]' 40 '--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]'
32 __docker_containers 41 __docker_containers
33 } 42 }
34 43
35 __build() { 44 __build() {
36 _arguments \ 45 _arguments \
37 '--no-cache[Do not use cache when building the image]' \ 46 '--no-cache[Do not use cache when building the image]' \
38 '(-q,--quiet)'{-q,--quiet}'[Suppress the verbose output generated by the containers]' \ 47 '(-q,--quiet)'{-q,--quiet}'[Suppress the verbose output generated by the containers]' \
39 '--rm[Remove intermediate containers after a successful build]' \ 48 '--rm[Remove intermediate containers after a successful build]' \
40 '(-t,--tag=)'{-t,--tag=}'[Repository name (and optionally a tag) to be applied to the resulting image in case of success]' \ 49 '(-t,--tag=)'{-t,--tag=}'[Repository name (and optionally a tag) to be applied to the resulting image in case of success]' \
41 '*:files:_files' 50 '*:files:_files'
42 } 51 }
43 52
44 __commit() { 53 __commit() {
45 _arguments \ 54 _arguments \
46 '(-a,--author=)'{-a,--author=}'[Author (eg. "John Hannibal Smith <hannibal@a-team.com>"]' \ 55 '(-a,--author=)'{-a,--author=}'[Author (eg. "John Hannibal Smith <hannibal@a-team.com>"]' \
47 '(-m,--message=)'{-m,--message=}'[Commit message]' \ 56 '(-m,--message=)'{-m,--message=}'[Commit message]' \
48 '--run=[Config automatically applied when the image is run.]' 57 '--run=[Config automatically applied when the image is run.]'
49 __docker_containers 58 __docker_containers
50 } 59 }
51 60
52 __cp() { 61 __cp() {
53 __docker_containers 62 __docker_containers
54 } 63 }
55 64
56 __diff() { 65 __diff() {
57 __docker_containers 66 __docker_containers
58 } 67 }
59 68
60 __events() { 69 __events() {
61 _arguments \ 70 _arguments \
62 '--since=[Show previously created events and then stream.]' 71 '--since=[Show previously created events and then stream.]'
63 } 72 }
64 73
65 __export() { 74 __export() {
66 __docker_containers 75 __docker_containers
67 } 76 }
68 77
69 __history() { 78 __history() {
70 _arguments \ 79 _arguments \
71 '--no-trunc=[Don''t truncate output]' \ 80 '--no-trunc=[Don''t truncate output]' \
72 '(-q,--quiet)'{-q,--quiet}'[Only show numeric IDs]' 81 '(-q,--quiet)'{-q,--quiet}'[Only show numeric IDs]'
73 __docker_images 82 __docker_images
74 } 83 }
75 84
76 __images() { 85 __images() {
77 _arguments \ 86 _arguments \
78 '(-a,--all)'{-a,--all}'[Show all images (by default filter out the intermediate images used to build)]' \ 87 '(-a,--all)'{-a,--all}'[Show all images (by default filter out the intermediate images used to build)]' \
79 '--no-trunc[Don''t truncate output]' \ 88 '--no-trunc[Don''t truncate output]' \
80 '(-q,--quiet=)'{-q,--quiet=}'[Only show numeric IDs]' \ 89 '(-q,--quiet=)'{-q,--quiet=}'[Only show numeric IDs]' \
81 '(-t,--tree=)'{-t,--tree=}'[Output graph in tree format]' \ 90 '(-t,--tree=)'{-t,--tree=}'[Output graph in tree format]' \
82 '(-v,--viz=)'{-v,--viz=}'[Output graph in graphviz format]' 91 '(-v,--viz=)'{-v,--viz=}'[Output graph in graphviz format]'
83 __docker_images 92 __docker_images
84 } 93 }
85 94
86 __import() { 95 __import() {
87 _arguments '*:files:_files' 96 _arguments '*:files:_files'
88 } 97 }
89 98
90 __info() { 99 __info() {
91 # no arguments 100 # no arguments
92 } 101 }
93 102
94 __insert() { 103 __insert() {
95 __docker_images 104 __docker_images
96 _arguments '*:files:_files' 105 _arguments '*:files:_files'
97 } 106 }
98 107
99 __inspect() { 108 __inspect() {
100 __docker_images 109 __docker_images
101 __docker_containers 110 __docker_all_containers
102 } 111 }
103 112
104 __kill() { 113 __kill() {
114 _arguments \
115 '(-s,--signal=)'{-s,--signal=}'[KILL Signal]'
105 __docker_containers 116 __docker_containers
106 } 117 }
107 118
108 __load() { 119 __load() {
109 _arguments '*:files:_files' 120 _arguments '*:files:_files'
110 } 121 }
111 122
112 __login() { 123 __login() {
113 _arguments \ 124 _arguments \
114 '(-e,--email=)'{-e,-email=}'[Email]' \ 125 '(-e,--email=)'{-e,-email=}'[Email]' \
115 '(-p,--password=)'{-p,-password=}'[Password]' \ 126 '(-p,--password=)'{-p,-password=}'[Password]' \
116 '(-u,--username=)'{-u,-username=}'[Username]' 127 '(-u,--username=)'{-u,-username=}'[Username]'
117 } 128 }
118 129
119 __logs() { 130 __logs() {
120 _arguments \ 131 _arguments \
121 '(-f,--follow)'{-f,-follow}'[Follow log output]' 132 '(-f,--follow)'{-f,-follow}'[Follow log output]'
122 __docker_containers 133 __docker_containers
123 } 134 }
124 135
125 __port() { 136 __port() {
126 __docker_containers 137 __docker_containers
127 } 138 }
128 139
129 __top() { 140 __top() {
130 __docker_containers 141 __docker_containers
131 } 142 }
132 143
133 __ps() { 144 __ps() {
134 _arguments \ 145 _arguments \
135 '(-a,--all)'{-a,--all}'[Show all containers. Only running containers are shown by default.]' \ 146 '(-a,--all)'{-a,--all}'[Show all containers. Only running containers are shown by default.]' \
136 '--before-id=[Show only container created before Id, include non-running ones.]' \ 147 '--before-id=[Show only container created before Id, include non-running ones.]' \
137 '(-l,--latest)'{-l,--latest}'[Show only the latest created container, include non-running ones.]' \ 148 '(-l,--latest)'{-l,--latest}'[Show only the latest created container, include non-running ones.]' \
138 '-n=[Show n last created containers, include non-running ones. default=-1.]' \ 149 '-n=[Show n last created containers, include non-running ones. default=-1.]' \
139 '--no-trunc[Don''t truncate output]' \ 150 '--no-trunc[Don''t truncate output]' \
140 '(-q,--quiet)'{-q,--quiet}'[Only display numeric IDs]' \ 151 '(-q,--quiet)'{-q,--quiet}'[Only display numeric IDs]' \
141 '(-s,--size)'{-s,--size}'[Display sizes]' \ 152 '(-s,--size)'{-s,--size}'[Display sizes]' \
142 '--since-id=[Show only containers created since Id, include non-running ones.]' 153 '--since-id=[Show only containers created since Id, include non-running ones.]'
143 } 154 }
144 155
145 __pull() { 156 __pull() {
146 _arguments \ 157 _arguments \
147 '(-t,--tag=)'{-t,--tag=}'[Download tagged image in repository]' 158 '(-t,--tag=)'{-t,--tag=}'[Download tagged image in repository]'
148 } 159 }
149 160
150 __push() { 161 __push() {
151 # no arguments 162 # no arguments
152 } 163 }
153 164
154 __restart() { 165 __restart() {
155 _arguments \ 166 _arguments \
156 '(-t,--time=)'{-t,--time=}'[Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10]' 167 '(-t,--time=)'{-t,--time=}'[Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10]'
157 __docker_containers 168 __docker_containers
158 } 169 }
159 170
160 __rm() { 171 __rm() {
161 _arguments \ 172 _arguments \
162 '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \ 173 '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \
163 '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \ 174 '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \
164 '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]' 175 '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]'
165 __docker_containers 176 __docker_all_containers
166 } 177 }
167 178
168 __rmi() { 179 __rmi() {
169 _arguments \ 180 _arguments \
170 '(-f,--force=)'{-f,--force=}'[Force]' 181 '(-f,--force=)'{-f,--force=}'[Force]'
171 __docker_images 182 __docker_images
172 } 183 }
173 184
174 __run() { 185 __run() {
175 _arguments \ 186 _arguments \
176 '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \ 187 '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \
177 '(-a,--attach=)'{-a,--attach=}'[Attach to stdin, stdout or stderr.]' \ 188 '(-a,--attach=)'{-a,--attach=}'[Attach to stdin, stdout or stderr.]' \
178 '(-c,--cpu-shares=)'{-c,--cpu-shares=}': CPU shares (relative weight)]' \ 189 '(-c,--cpu-shares=)'{-c,--cpu-shares=}': CPU shares (relative weight)]' \
179 '--cidfile=[Write the container ID to the file]' \ 190 '--cidfile=[Write the container ID to the file]' \
180 '(-d,--detach=)'{-d,--detach=}'[Detached mode: Run container in the background, print new container id]' \ 191 '(-d,--detach=)'{-d,--detach=}'[Detached mode: Run container in the background, print new container id]' \
181 '--dns=[Set custom dns servers]' \ 192 '--dns=[Set custom dns servers]' \
182 '(-e,--env=)'{-e,--env=}'[Set environment variables]' \ 193 '(-e,--env=)'{-e,--env=}'[Set environment variables]' \
183 '--entrypoint=[Overwrite the default entrypoint of the image]' \ 194 '--entrypoint=[Overwrite the default entrypoint of the image]' \
184 '--expose=[Expose a port from the container without publishing it to your host]' \ 195 '--expose=[Expose a port from the container without publishing it to your host]' \
185 '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \ 196 '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \
186 '(-i,--interactive=)'{-i,--interactive=}'[Keep stdin open even if not attached]' \ 197 '(-i,--interactive=)'{-i,--interactive=}'[Keep stdin open even if not attached]' \
187 '--link=[Add link to another container (name:alias)]' \ 198 '--link=[Add link to another container (name:alias)]' \
188 '--lxc-conf=[Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"]' \ 199 '--lxc-conf=[Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"]' \
189 '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \ 200 '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \
190 '(-n,--networking=)'{-n,--networking=}'[Enable networking for this container]' \ 201 '(-n,--networking=)'{-n,--networking=}'[Enable networking for this container]' \
191 '--name=[Assign a name to the container]' \ 202 '--name=[Assign a name to the container]' \
192 '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) (use "docker port" to see the actual mapping)]' \ 203 '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) (use "docker port" to see the actual mapping)]' \
193 '--privileged=[Give extended privileges to this container]' \ 204 '--privileged=[Give extended privileges to this container]' \
194 '--rm=[Automatically remove the container when it exits (incompatible with -d)]' \ 205 '--rm=[Automatically remove the container when it exits (incompatible with -d)]' \
195 '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \ 206 '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \
196 '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \ 207 '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \
197 '(-u,--user=)'{-u,--user=}'[Username or UID]' \ 208 '(-u,--user=)'{-u,--user=}'[Username or UID]' \
198 '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \ 209 '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \
199 '--volumes-from=[Mount volumes from the specified container(s)]' \ 210 '--volumes-from=[Mount volumes from the specified container(s)]' \
200 '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]' 211 '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]'
201 __docker_images 212 __docker_images
202 } 213 }
203 214
204 __search() { 215 __search() {
205 _arguments \ 216 _arguments \
206 '--no-trunc=[Don''t truncate output]' \ 217 '--no-trunc=[Don''t truncate output]' \
207 '-s,--stars=)'{-s,--stars=}'[Only displays with at least xxx stars]' \ 218 '-s,--stars=)'{-s,--stars=}'[Only displays with at least xxx stars]' \
208 '-t,--trusted=)'{-t,--trusted=}'[Only show trusted builds]' 219 '-t,--trusted=)'{-t,--trusted=}'[Only show trusted builds]'
209 } 220 }
210 221
211 __save() { 222 __save() {
212 __docker_images 223 __docker_images
213 } 224 }
214 225
215 __start() { 226 __start() {
216 _arguments \ 227 _arguments \
217 '(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \ 228 '(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \
218 '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s stdin]' 229 '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s stdin]'
219 __docker_containers 230 __docker_all_containers
220 } 231 }
221 232
222 __stats() { 233 __stats() {
223 __docker_containers 234 __docker_containers
224 } 235 }
225 236
226 __stop() { 237 __stop() {
227 _arguments \ 238 _arguments \
228 '(-t,--time=)'{-t,--time=}'[Number of seconds to wait for the container to stop before killing it.]' 239 '(-t,--time=)'{-t,--time=}'[Number of seconds to wait for the container to stop before killing it.]'
229 __docker_containers 240 __docker_containers
230 } 241 }
231 242
232 __tag() { 243 __tag() {
233 _arguments \ 244 _arguments \
234 '(-f,--force=)'{-f,--force=}'[Force]' 245 '(-f,--force=)'{-f,--force=}'[Force]'
235 __docker_images 246 __docker_images
236 } 247 }
237 248
238 __version() { 249 __version() {
239 # no arguments 250 # no arguments
240 } 251 }
241 252
242 __wait() { 253 __wait() {
243 __docker_containers 254 __docker_containers
244 } 255 }
245 256
246 __exec() { 257 __exec() {
247 _arguments \ 258 _arguments \
248 '(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \ 259 '(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \
249 '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \ 260 '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
250 '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]' 261 '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]'
251 __docker_containers 262 __docker_containers
252 } 263 }
253 264
254 # end commands --------- 265 # end commands ---------
255 # ---------------------- 266 # ----------------------
256 267
257 local -a _1st_arguments 268 local -a _1st_arguments
258 _1st_arguments=( 269 _1st_arguments=(
259 "attach":"Attach to a running container" 270 "attach":"Attach to a running container"
260 "build":"Build a container from a Dockerfile" 271 "build":"Build a container from a Dockerfile"
261 "commit":"Create a new image from a container's changes" 272 "commit":"Create a new image from a container's changes"
262 "cp":"Copy files/folders from the containers filesystem to the host path" 273 "cp":"Copy files/folders from the containers filesystem to the host path"
263 "diff":"Inspect changes on a container's filesystem" 274 "diff":"Inspect changes on a container's filesystem"
264 "events":"Get real time events from the server" 275 "events":"Get real time events from the server"
265 "export":"Stream the contents of a container as a tar archive" 276 "export":"Stream the contents of a container as a tar archive"
266 "history":"Show the history of an image" 277 "history":"Show the history of an image"
267 "images":"List images" 278 "images":"List images"
268 "import":"Create a new filesystem image from the contents of a tarball" 279 "import":"Create a new filesystem image from the contents of a tarball"
269 "info":"Display system-wide information" 280 "info":"Display system-wide information"
270 "insert":"Insert a file in an image" 281 "insert":"Insert a file in an image"
271 "inspect":"Return low-level information on a container" 282 "inspect":"Return low-level information on a container"
272 "kill":"Kill a running container" 283 "kill":"Kill a running container"
273 "load":"Load an image from a tar archive" 284 "load":"Load an image from a tar archive"
274 "login":"Register or Login to the docker registry server" 285 "login":"Register or Login to the docker registry server"
275 "logs":"Fetch the logs of a container" 286 "logs":"Fetch the logs of a container"
276 "port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT" 287 "port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"
277 "ps":"List containers" 288 "ps":"List containers"
278 "pull":"Pull an image or a repository from the docker registry server" 289 "pull":"Pull an image or a repository from the docker registry server"
279 "push":"Push an image or a repository to the docker registry server" 290 "push":"Push an image or a repository to the docker registry server"
280 "restart":"Restart a running container" 291 "restart":"Restart a running container"
281 "rm":"Remove one or more containers" 292 "rm":"Remove one or more containers"
282 "rmi":"Remove one or more images" 293 "rmi":"Remove one or more images"
283 "run":"Run a command in a new container" 294 "run":"Run a command in a new container"
284 "save":"Save an image to a tar archive" 295 "save":"Save an image to a tar archive"
285 "search":"Search for an image in the docker index" 296 "search":"Search for an image in the docker index"
286 "start":"Start a stopped container" 297 "start":"Start a stopped container"
287 "stats":"Display a live stream of one or more containers' resource usage statistics" 298 "stats":"Display a live stream of one or more containers' resource usage statistics"
288 "stop":"Stop a running container" 299 "stop":"Stop a running container"
289 "tag":"Tag an image into a repository" 300 "tag":"Tag an image into a repository"
290 "top":"Lookup the running processes of a container" 301 "top":"Lookup the running processes of a container"
291 "version":"Show the docker version information" 302 "version":"Show the docker version information"
292 "wait":"Block until a container stops, then print its exit code" 303 "wait":"Block until a container stops, then print its exit code"
293 "exec":"Run a task inside a running container" 304 "exec":"Run a task inside a running container"
294 ) 305 )
295 306
296 _arguments '*:: :->command' 307 _arguments '*:: :->command'
297 308
298 if (( CURRENT == 1 )); then 309 if (( CURRENT == 1 )); then
299 _describe -t commands "docker command" _1st_arguments 310 _describe -t commands "docker command" _1st_arguments
300 return 311 return
301 fi 312 fi
302 313
303 local -a _command_args 314 local -a _command_args
304 case "$words[1]" in 315 case "$words[1]" in
305 attach) 316 attach)
306 __attach ;; 317 __attach ;;
307 build) 318 build)
308 __build ;; 319 __build ;;
309 commit) 320 commit)
310 __commit ;; 321 __commit ;;
311 cp) 322 cp)
312 __cp ;; 323 __cp ;;
313 diff) 324 diff)
314 __diff ;; 325 __diff ;;
315 events) 326 events)
316 __events ;; 327 __events ;;
317 export) 328 export)
318 __export ;; 329 __export ;;
319 history) 330 history)
320 __history ;; 331 __history ;;
321 images) 332 images)
322 __images ;; 333 __images ;;
323 import) 334 import)
324 __import ;; 335 __import ;;
325 info) 336 info)
326 __info ;; 337 __info ;;
327 insert) 338 insert)
328 __insert ;; 339 __insert ;;
329 inspect) 340 inspect)
330 __inspect ;; 341 __inspect ;;
331 kill) 342 kill)
332 __kill ;; 343 __kill ;;
333 load) 344 load)
334 __load ;; 345 __load ;;
335 login) 346 login)
336 __login ;; 347 __login ;;
337 logs) 348 logs)
338 __logs ;; 349 __logs ;;
339 port) 350 port)
340 __port ;; 351 __port ;;
341 ps) 352 ps)
342 __ps ;; 353 __ps ;;
343 pull) 354 pull)
344 __pull ;; 355 __pull ;;
345 push) 356 push)
346 __push ;; 357 __push ;;
347 restart) 358 restart)
348 __restart ;; 359 __restart ;;
349 rm) 360 rm)
350 __rm ;; 361 __rm ;;
351 rmi) 362 rmi)
352 __rmi ;; 363 __rmi ;;
353 run) 364 run)
354 __run ;; 365 __run ;;
355 save) 366 save)
356 __save ;; 367 __save ;;
357 search) 368 search)
358 __search ;; 369 __search ;;
359 stats) 370 stats)
360 __stats ;; 371 __stats ;;
361 start) 372 start)
362 __start ;; 373 __start ;;
363 stop) 374 stop)
364 __stop ;; 375 __stop ;;
365 tag) 376 tag)
366 __tag ;; 377 __tag ;;
367 top) 378 top)
368 __top ;; 379 __top ;;
369 version) 380 version)
370 __version ;; 381 __version ;;
371 wait) 382 wait)
372 __wait ;; 383 __wait ;;
373 exec) 384 exec)
374 __exec ;; 385 __exec ;;
375 esac 386 esac
376 387
plugins/frontend-search/README.md
1 ## Rationale ## 1 ## Rationale ##
2 2
3 The idea for this script is to help searches in important doc contents from frontend. 3 > Searches for your Frontend contents more easier
4
4 5
5 ## Instalation ## 6 ## Instalation ##
6 7
7 I will send a Pull Request with this plugin for .oh-my-zsh official repository. If accept them, it's only add in plugins list that exists in ```.zshrc``` file.
8 8
9 For now, you can clone this repository and add in ```custom/plugins``` folder 9 Open your `.zshrc` file and load `frontend-search` plugin
10
11 ```bash
12 $ git clone git://github.com/willmendesneto/frontend-search.git ~/.oh-my-zsh/custom/plugins/frontend-search
13 ```
14
15 After this, restart your terminal and frontend-search plugin is configurated in you CLI.
16 10
17 ```bash 11 ```bash
18 ... 12 ...
19 plugins=( <your-plugins-list>... frontend-search) 13 plugins=( <your-plugins-list>... frontend-search)
20 ... 14 ...
21 ``` 15 ```
22 16
17
23 ## Commands ## 18 ## Commands ##
24 19
25 All command searches are accept only in format 20 All command searches are accept only in format
26 21
27 * `frontend <search-content> <search-term>` 22 * `frontend <search-content> <search-term>`
28 23
29 The search content are 24 The search content are
30 25
31 * `jquery <api.jquery.com>` 26 * `jquery <api.jquery.com>`
32 * `mdn <developer.mozilla.org>` 27 * `mdn <developer.mozilla.org>`
33 * `compass <compass-style.org>` 28 * `compass <compass-style.org>`
34 * `html5please <html5please.com>` 29 * `html5please <html5please.com>`
35 * `caniuse <caniuse.com>` 30 * `caniuse <caniuse.com>`
36 * `aurajs <aurajs.com>` 31 * `aurajs <aurajs.com>`
37 * `dartlang <api.dartlang.org/apidocs/channels/stable/dartdoc-viewer>` 32 * `dartlang <api.dartlang.org/apidocs/channels/stable/dartdoc-viewer>`
38 * `lodash <search>` 33 * `lodash <search>`
39 * `qunit <api.qunitjs.com>` 34 * `qunit <api.qunitjs.com>`
40 * `fontello <fontello.com>` 35 * `fontello <fontello.com>`
41 * `bootsnipp <bootsnipp.com>` 36 * `bootsnipp <bootsnipp.com>`
42 * `cssflow <cssflow.com>` 37 * `cssflow <cssflow.com>`
43 * `codepen <codepen.io>` 38 * `codepen <codepen.io>`
44 * `unheap <www.unheap.com>` 39 * `unheap <www.unheap.com>`
45 * `bem <google.com/search?as_q=<search-term>&as_sitesearch=bem.info>` 40 * `bem <google.com/search?as_q=<search-term>&as_sitesearch=bem.info>`
46 * `smacss <google.com/search?as_q=<search-term>&as_sitesearch=smacss.com>` 41 * `smacss <google.com/search?as_q=<search-term>&as_sitesearch=smacss.com>`
47 * `angularjs <google.com/search?as_q=<search-term>&as_sitesearch=angularjs.org>` 42 * `angularjs <google.com/search?as_q=<search-term>&as_sitesearch=angularjs.org>`
48 * `reactjs <google.com/search?as_q=<search-term>&as_sitesearch=facebook.github.io/react>` 43 * `reactjs <google.com/search?as_q=<search-term>&as_sitesearch=facebook.github.io/react>`
49 * `emberjs <emberjs.com>` 44 * `emberjs <emberjs.com>`
45 * `stackoverflow <stackoverflow.com>`
50 46
51 47
52 ## Aliases ## 48 ## Aliases ##
53 49
54 There are a few aliases presented as well: 50 There are a few aliases presented as well:
55 51
56 * `jquery` A shorthand for `frontend jquery` 52 * `jquery` A shorthand for `frontend jquery`
57 * `mdn` A shorthand for `frontend mdn` 53 * `mdn` A shorthand for `frontend mdn`
58 * `compass` A shorthand for `frontend compass` 54 * `compass` A shorthand for `frontend compass`
59 * `html5please` A shorthand for `frontend html5please` 55 * `html5please` A shorthand for `frontend html5please`
60 * `caniuse` A shorthand for `frontend caniuse` 56 * `caniuse` A shorthand for `frontend caniuse`
61 * `aurajs` A shorthand for `frontend aurajs` 57 * `aurajs` A shorthand for `frontend aurajs`
62 * `dartlang` A shorthand for `frontend dartlang` 58 * `dartlang` A shorthand for `frontend dartlang`
63 * `lodash` A shorthand for `frontend lodash` 59 * `lodash` A shorthand for `frontend lodash`
64 * `qunit` A shorthand for `frontend qunit` 60 * `qunit` A shorthand for `frontend qunit`
65 * `fontello` A shorthand for `frontend fontello` 61 * `fontello` A shorthand for `frontend fontello`
66 * `bootsnipp` A shorthand for `frontend bootsnipp` 62 * `bootsnipp` A shorthand for `frontend bootsnipp`
67 * `cssflow` A shorthand for `frontend cssflow` 63 * `cssflow` A shorthand for `frontend cssflow`
68 * `codepen` A shorthand for `frontend codepen` 64 * `codepen` A shorthand for `frontend codepen`
69 * `unheap` A shorthand for `frontend unheap` 65 * `unheap` A shorthand for `frontend unheap`
70 * `bem` A shorthand for `frontend bem` 66 * `bem` A shorthand for `frontend bem`
71 * `smacss` A shorthand for `frontend smacss` 67 * `smacss` A shorthand for `frontend smacss`
72 * `angularjs` A shorthand for `frontend angularjs` 68 * `angularjs` A shorthand for `frontend angularjs`
73 * `reactjs` A shorthand for `frontend reactjs` 69 * `reactjs` A shorthand for `frontend reactjs`
74 * `emberjs` A shorthand for `frontend emberjs` 70 * `emberjs` A shorthand for `frontend emberjs`
71 * `stackoverflow` A shorthand for `frontend stackoverflow`
72
75 73
76 ## Author 74 ## Author
77 75
78 **Wilson Mendes (willmendesneto)** 76 **Wilson Mendes (willmendesneto)**
plugins/frontend-search/_frontend-search.sh
File was created 1 #compdef frontend
2
3 zstyle ':completion:*:descriptions' format '%B%d%b'
4 zstyle ':completion::complete:frontend:*:commands' group-name commands
5 zstyle ':completion::complete:frontend:*:frontend_points' group-name frontend_points
6 zstyle ':completion::complete:frontend::' list-grouped
7
8 zmodload zsh/mapfile
9
10 function _frontend() {
11 local CONFIG=$HOME/.frontend-search
12 local ret=1
13
14 local -a commands
15 local -a frontend_points
16
17 frontend_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
18
19 commands=(
20 'jquery: Search in jQuery website'
21 'mdn: Search in MDN website'
22 'compass: Search in COMPASS website'
23 'html5please: Search in HTML5 Please website'
24 'caniuse: Search in Can I Use website'
25 'aurajs: Search in AuraJs website'
26 'dartlang: Search in Dart website'
27 'lodash: Search in Lo-Dash website'
28 'qunit: Search in Qunit website'
29 'fontello: Search in fontello website'
30 'bootsnipp: Search in bootsnipp website'
31 'cssflow: Search in cssflow website'
32 'codepen: Search in codepen website'
33 'unheap: Search in unheap website'
34 'bem: Search in BEM website'
35 'smacss: Search in SMACSS website'
36 'angularjs: Search in Angular website'
37 'reactjs: Search in React website'
38 'emberjs: Search in Ember website'
39 'stackoverflow: Search in StackOverflow website'
40 )
41
42 _arguments -C \
43 '1: :->first_arg' \
44 '2: :->second_arg' && ret=0
45
46 case $state in
47 first_arg)
48 _describe -t frontend_points "Warp points" frontend_points && ret=0
49 _describe -t commands "Commands" commands && ret=0
50 ;;
51 second_arg)
52 case $words[2] in
53 jquery)
54 _describe -t points "Warp points" frontend_points && ret=0
55 ;;
56 mdn)
57 _describe -t points "Warp points" frontend_points && ret=0
58 ;;
59 compass)
60 _describe -t points "Warp points" frontend_points && ret=0
61 ;;
62 html5please)
63 _describe -t points "Warp points" frontend_points && ret=0
64 ;;
65 caniuse)
66 _describe -t points "Warp points" frontend_points && ret=0
67 ;;
68 aurajs)
69 _describe -t points "Warp points" frontend_points && ret=0
70 ;;
71 dartlang)
72 _describe -t points "Warp points" frontend_points && ret=0
73 ;;
74 lodash)
75 _describe -t points "Warp points" frontend_points && ret=0
76 ;;
77 qunit)
78 _describe -t points "Warp points" frontend_points && ret=0
79 ;;
80 fontello)
81 _describe -t points "Warp points" frontend_points && ret=0
82 ;;
83 bootsnipp)
84 _describe -t points "Warp points" frontend_points && ret=0
85 ;;
86 cssflow)
87 _describe -t points "Warp points" frontend_points && ret=0
88 ;;
89 codepen)
90 _describe -t points "Warp points" frontend_points && ret=0
91 ;;
92 unheap)
93 _describe -t points "Warp points" frontend_points && ret=0
94 ;;
95 bem)
96 _describe -t points "Warp points" frontend_points && ret=0
97 ;;
98 smacss)
99 _describe -t points "Warp points" frontend_points && ret=0
100 ;;
101 angularjs)
102 _describe -t points "Warp points" frontend_points && ret=0
103 ;;
104 reactjs)
105 _describe -t points "Warp points" frontend_points && ret=0
106 ;;
107 emberjs)
108 _describe -t points "Warp points" frontend_points && ret=0
109 ;;
110 stackoverflow)
111 _describe -t points "Warp points" frontend_points && ret=0
112 ;;
113 esac
114 ;;
115 esac
116
117 return $ret
118 }
119
120 _frontend "$@"
121
122 # Local Variables:
123 # mode: Shell-Script
124 # sh-indentation: 2
125 # indent-tabs-mode: nil
126 # sh-basic-offset: 2
127 # End:
128 # vim: ft=zsh sw=2 ts=2 et
129
plugins/frontend-search/frontend-search.plugin.zsh
1 # frontend from terminal 1 # frontend from terminal
2 2
3 function frontend() { 3 function frontend() {
4 4
5 # get the open command 5 # get the open command
6 local open_cmd 6 local open_cmd
7 if [[ $(uname -s) == 'Darwin' ]]; then 7 if [[ $(uname -s) == 'Darwin' ]]; then
8 open_cmd='open' 8 open_cmd='open'
9 else 9 else
10 open_cmd='xdg-open' 10 open_cmd='xdg-open'
11 fi 11 fi
12 12
13 # no keyword provided, simply show how call methods 13 # no keyword provided, simply show how call methods
14 if [[ $# -le 1 ]]; then 14 if [[ $# -le 1 ]]; then
15 echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n" 15 echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n"
16 return 1 16 return 1
17 fi 17 fi
18 18
19 # check whether the search engine is supported 19 # check whether the search engine is supported
20 if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs)' ]]; 20 if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow)' ]];
21 then 21 then
22 echo "Search valid search content $1 not supported." 22 echo "Search valid search content $1 not supported."
23 echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')" 23 echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')"
24 echo "* jquery" 24 echo "* jquery"
25 echo "* mdn" 25 echo "* mdn"
26 echo "* compass" 26 echo "* compass"
27 echo "* html5please" 27 echo "* html5please"
28 echo "* caniuse" 28 echo "* caniuse"
29 echo "* aurajs" 29 echo "* aurajs"
30 echo "* dartlang" 30 echo "* dartlang"
31 echo "* lodash" 31 echo "* lodash"
32 echo "* qunit" 32 echo "* qunit"
33 echo "* fontello" 33 echo "* fontello"
34 echo "* bootsnipp" 34 echo "* bootsnipp"
35 echo "* cssflow" 35 echo "* cssflow"
36 echo "* codepen" 36 echo "* codepen"
37 echo "* unheap" 37 echo "* unheap"
38 echo "* bem" 38 echo "* bem"
39 echo "* smacss" 39 echo "* smacss"
40 echo "* angularjs" 40 echo "* angularjs"
41 echo "* reactjs" 41 echo "* reactjs"
42 echo "* emberjs" 42 echo "* emberjs"
43 echo "* stackoverflow"
43 echo "" 44 echo ""
44 45
45 return 1 46 return 1
46 fi 47 fi
47 48
48 local url="http://" 49 local url="http://"
49 local query="" 50 local query=""
50 51
51 case "$1" in 52 case "$1" in
52 "jquery") 53 "jquery")
53 url="${url}api.jquery.com" 54 url="${url}api.jquery.com"
54 url="${url}/?s=$2" ;; 55 url="${url}/?s=$2" ;;
55 "mdn") 56 "mdn")
56 url="${url}developer.mozilla.org" 57 url="${url}developer.mozilla.org"
57 url="${url}/search?q=$2" ;; 58 url="${url}/search?q=$2" ;;
58 "compass") 59 "compass")
59 url="${url}compass-style.org" 60 url="${url}compass-style.org"
60 url="${url}/search?q=$2" ;; 61 url="${url}/search?q=$2" ;;
61 "html5please") 62 "html5please")
62 url="${url}html5please.com" 63 url="${url}html5please.com"
63 url="${url}/#$2" ;; 64 url="${url}/#$2" ;;
64 "caniuse") 65 "caniuse")
65 url="${url}caniuse.com" 66 url="${url}caniuse.com"
66 url="${url}/#search=$2" ;; 67 url="${url}/#search=$2" ;;
67 "aurajs") 68 "aurajs")
68 url="${url}aurajs.com" 69 url="${url}aurajs.com"
69 url="${url}/api/#stq=$2" ;; 70 url="${url}/api/#stq=$2" ;;
70 "dartlang") 71 "dartlang")
71 url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer" 72 url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer"
72 url="${url}/dart-$2" ;; 73 url="${url}/dart-$2" ;;
73 "qunit") 74 "qunit")
74 url="${url}api.qunitjs.com" 75 url="${url}api.qunitjs.com"
75 url="${url}/?s=$2" ;; 76 url="${url}/?s=$2" ;;
76 "fontello") 77 "fontello")
77 url="${url}fontello.com" 78 url="${url}fontello.com"
78 url="${url}/#search=$2" ;; 79 url="${url}/#search=$2" ;;
79 "bootsnipp") 80 "bootsnipp")
80 url="${url}bootsnipp.com" 81 url="${url}bootsnipp.com"
81 url="${url}/search?q=$2" ;; 82 url="${url}/search?q=$2" ;;
82 "cssflow") 83 "cssflow")
83 url="${url}cssflow.com" 84 url="${url}cssflow.com"
84 url="${url}/search?q=$2" ;; 85 url="${url}/search?q=$2" ;;
85 "codepen") 86 "codepen")
86 url="${url}codepen.io" 87 url="${url}codepen.io"
87 url="${url}/search?q=$2" ;; 88 url="${url}/search?q=$2" ;;
88 "unheap") 89 "unheap")
89 url="${url}www.unheap.com" 90 url="${url}www.unheap.com"
90 url="${url}/?s=$2" ;; 91 url="${url}/?s=$2" ;;
91 "bem") 92 "bem")
92 url="${url}google.com" 93 url="${url}google.com"
93 url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;; 94 url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;;
94 "smacss") 95 "smacss")
95 url="${url}google.com" 96 url="${url}google.com"
96 url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;; 97 url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;;
97 "angularjs") 98 "angularjs")
98 url="${url}google.com" 99 url="${url}google.com"
99 url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;; 100 url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;;
100 "reactjs") 101 "reactjs")
101 url="${url}google.com" 102 url="${url}google.com"
102 url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;; 103 url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;;
103 "emberjs") 104 "emberjs")
104 url="${url}emberjs.com" 105 url="${url}emberjs.com"
105 url="${url}/api/#stq=$2&stp=1" ;; 106 url="${url}/api/#stq=$2&stp=1" ;;
107 "stackoverflow")
108 url="${url}stackoverflow.com"
109 url="${url}/search?q=$2" ;;
106 *) echo "INVALID PARAM!" 110 *) echo "INVALID PARAM!"
107 return ;; 111 return ;;
108 esac 112 esac
109 113
110 echo "$url" 114 echo "$url"
111 115
112 $open_cmd "$url" 116 $open_cmd "$url"
113 117
114 } 118 }
115 119
116 # javascript 120 # javascript
117 alias jquery='frontend jquery' 121 alias jquery='frontend jquery'
118 alias mdn='frontend mdn' 122 alias mdn='frontend mdn'
119 123
120 # pre processors frameworks 124 # pre processors frameworks
121 alias compassdoc='frontend compass' 125 alias compassdoc='frontend compass'
122 126
123 # important links 127 # important links
124 alias html5please='frontend html5please' 128 alias html5please='frontend html5please'
125 alias caniuse='frontend caniuse' 129 alias caniuse='frontend caniuse'
126 130
127 # components and libraries 131 # components and libraries
128 alias aurajs='frontend aurajs' 132 alias aurajs='frontend aurajs'
129 alias dartlang='frontend dartlang' 133 alias dartlang='frontend dartlang'
130 alias lodash='frontend lodash' 134 alias lodash='frontend lodash'
131 135
132 #tests 136 #tests
133 alias qunit='frontend qunit' 137 alias qunit='frontend qunit'
134 138
135 #fonts 139 #fonts
136 alias fontello='frontend fontello' 140 alias fontello='frontend fontello'
137 141
138 # snippets 142 # snippets
139 alias bootsnipp='frontend bootsnipp' 143 alias bootsnipp='frontend bootsnipp'
140 alias cssflow='frontend cssflow' 144 alias cssflow='frontend cssflow'
141 alias codepen='frontend codepen' 145 alias codepen='frontend codepen'
142 alias unheap='frontend unheap' 146 alias unheap='frontend unheap'
143 147
144 # css architecture 148 # css architecture
145 alias bem='frontend bem' 149 alias bem='frontend bem'
146 alias smacss='frontend smacss' 150 alias smacss='frontend smacss'
147 151
148 # frameworks 152 # frameworks
149 alias angularjs='frontend angularjs' 153 alias angularjs='frontend angularjs'
150 alias reactjs='frontend reactjs' 154 alias reactjs='frontend reactjs'
151 alias emberjs='frontend emberjs' 155 alias emberjs='frontend emberjs'
156
157 # search websites
158 alias stackoverflow='frontend stackoverflow'
152 159