Unverified Commit 8c95c523 authored by Kozlov Alexander's avatar Kozlov Alexander Committed by GitHub
Browse files

Merge branch 'master' into master

parents dd30cf10 3d8f2bda
# Cpanm
This plugin provides completion for [Cpanm](https://github.com/miyagawa/cpanminus) ([docs](https://metacpan.org/pod/App::cpanminus)).
To use it add cpanm to the plugins array in your zshrc file.
```bash
plugins=(... cpanm)
```
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
# #
# Current supported cpanm version: 1.4000 (Tue Mar 8 01:00:49 PST 2011) # Current supported cpanm version: 1.4000 (Tue Mar 8 01:00:49 PST 2011)
# #
# The latest code is always located at:
# https://github.com/rshhh/cpanminus/blob/master/etc/_cpanm
#
local arguments curcontext="$curcontext" local arguments curcontext="$curcontext"
typeset -A opt_args typeset -A opt_args
......
# Usage: dash [keyword:]query
dash() { open dash://"$*" }
compdef _dash dash
_dash() {
# No sense doing this for anything except the 2nd position and if we haven't
# specified which docset to query against
if [[ $CURRENT -eq 2 && ! "$words[2]" =~ ":" ]]; then
local -a _all_docsets
_all_docsets=()
# Use defaults to get the array of docsets from preferences
# Have to smash it into one big line so that each docset is an element of
# our DOCSETS array
DOCSETS=("${(@f)$(defaults read com.kapeli.dashdoc docsets | tr -d '\n' | grep -oE '\{.*?\}')}")
# remove all newlines since defaults prints so pretty like
# Now get each docset and output each on their own line
for doc in "$DOCSETS[@]"; do
# Only output docsets that are actually enabled
if [[ "`echo $doc | grep -Eo \"isEnabled = .*?;\" | sed 's/[^01]//g'`" == "0" ]]; then
continue
fi
keyword=''
# Order of preference as explained to me by @kapeli via email
KEYWORD_LOCATORS=(keyword suggestedKeyword platform)
for locator in "$KEYWORD_LOCATORS[@]"; do
# Echo the docset, try to find the appropriate keyword
# Strip doublequotes and colon from any keyword so that everything has the
# same format when output (we'll add the colon in the completion)
keyword=`echo $doc | grep -Eo "$locator = .*?;" | sed -e "s/$locator = \(.*\);/\1/" -e "s/[\":]//g"`
if [[ ! -z "$keyword" ]]; then
# if we fall back to platform, we should do some checking per @kapeli
if [[ "$locator" == "platform" ]]; then
# Since these are the only special cases right now, let's not do the
# expensive processing unless we have to
if [[ "$keyword" == "python" || "$keyword" == "java" || \
"$keyword" == "qt" || "$keyword" == "cocs2d" ]]; then
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"`
if [[ "$keyword" == "python" ]]; then
if [[ "$docsetName" == "Python 2" ]]; then
keyword="python2"
elif [[ "$docsetName" == "Python 3" ]]; then
keyword="python3"
fi
elif [[ "$keyword" == "java" ]]; then
if [[ "$docsetName" == "Java SE7" ]]; then
keyword="java7"
elif [[ "$docsetName" == "Java SE6" ]]; then
keyword="java6"
elif [[ "$docsetName" == "Java SE8" ]]; then
keyword="java8"
fi
elif [[ "$keyword" == "qt" ]]; then
if [[ "$docsetName" == "Qt 5" ]]; then
keyword="qt5"
elif [[ "$docsetName" == "Qt 4" ]]; then
keyword="qt4"
elif [[ "$docsetName" == "Qt" ]]; then
keyword="qt4"
fi
elif [[ "$keyword" == "cocos2d" ]]; then
if [[ "$docsetName" == "Cocos3D" ]]; then
keyword="cocos3d"
fi
fi
fi
fi
# Bail once we have a match
break
fi
done
# If we have a keyword, add it to the list!
if [[ ! -z "$keyword" ]]; then
_all_docsets+=($keyword)
fi
done
# special thanks to [arx] on #zsh for getting me sorted on this piece
compadd -qS: -- "$_all_docsets[@]"
return
fi
}
...@@ -5,9 +5,12 @@ ...@@ -5,9 +5,12 @@
# #
# Debian-related zsh aliases and functions for zsh # Debian-related zsh aliases and functions for zsh
# Use aptitude if installed, or apt-get if not. # Use apt or aptitude if installed, fallback is apt-get
# You can just set apt_pref='apt-get' to override it. # You can just set apt_pref='apt-get' to override it.
if [[ -e $( which -p aptitude 2>&1 ) ]]; then if [[ -e $( which -p apt 2>&1 ) ]]; then
apt_pref='apt'
apt_upgr='upgrade'
elif [[ -e $( which -p aptitude 2>&1 ) ]]; then
apt_pref='aptitude' apt_pref='aptitude'
apt_upgr='safe-upgrade' apt_upgr='safe-upgrade'
else else
...@@ -176,7 +179,7 @@ apt-copy() { ...@@ -176,7 +179,7 @@ apt-copy() {
# apt-history remove # apt-history remove
# apt-history rollback # apt-history rollback
# apt-history list # apt-history list
# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html # Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
apt-history () { apt-history () {
case "$1" in case "$1" in
install) install)
......
# dircycle
Plugin for cycling through the directory stack
This plugin enables directory navigation similar to using back and forward on browsers or common file explorers like Finder or Nautilus. It uses a small zle trick that lets you cycle through your directory stack left or right using <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> / <kbd>Right</kbd> . This is useful when moving back and forth between directories in development environments, and can be thought of as kind of a nondestructive pushd/popd.
## Enabling the plugin
1. Open your `.zshrc` file and add `dircycle` in the plugins section:
```zsh
plugins=(
# all your enabled plugins
dircycle
)
```
2. Reload the source file or restart your Terminal session:
```console
$ source ~/.zshrc
$
```
## Usage Examples
Say you opened these directories on the terminal:
```console
~$ cd Projects
~/Projects$ cd Hacktoberfest
~/Projects/Hacktoberfest$ cd oh-my-zsh
~/Projects/Hacktoberfest/oh-my-zsh$ dirs -v
0 ~/Projects/Hacktoberfest/oh-my-zsh
1 ~/Projects/Hacktoberfest
2 ~/Projects
3 ~
```
By pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd>, the current working directory or `$CWD` will be from `oh-my-zsh` to `Hacktoberfest`. Press it again and it will be at `Projects`.
And by pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd>, the `$CWD` will be from `Projects` to `Hacktoberfest`. Press it again and it will be at `oh-my-zsh`.
Here's a example history table with the same accessed directories like above:
| Current `$CWD` | Key press | New `$CWD` |
| --------------- | ----------------------------------------------------- | --------------- |
| `oh-my-zsh` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> | `Hacktoberfest` |
| `Hacktoberfest` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> | `Projects` |
| `Projects` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> | `~` |
| `~` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `Projects` |
| `Projects` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `Hacktoberfest` |
| `Hacktoberfest` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `oh-my-zsh` |
| `oh-my-zsh` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `~` |
Note the last traversal, when pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> on a last known `$CWD`, it will change back to the first known `$CWD`, which in the example is `~`.
Here's an asciinema cast demonstrating the example above:
[![asciicast](https://asciinema.org/a/204406.png)](https://asciinema.org/a/204406)
## Functions
| Function | Description |
| -------------------- | --------------------------------------------------------------------------------------------------------- |
| `insert-cycledleft` | Change `$CWD` to the previous known stack, binded on <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> |
| `insert-cycledright` | Change `$CWD` to the next known stack, binded on <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> |
## Rebinding keys
You can bind these functions to other key sequences, as long as you know the bindkey sequence. For example, these commands bind to <kbd>Alt</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> / <kbd>Right</kbd> in `xterm-256color`:
```zsh
bindkey '^[[1;4D' insert-cycledleft
bindkey '^[[1;4C' insert-cycledright
```
You can get the bindkey sequence by pressing <kbd>Ctrl</kbd> + <kbd>V</kbd>, then pressing the keyboard shortcut you want to use.
...@@ -9,31 +9,36 @@ ...@@ -9,31 +9,36 @@
# pushd -N: start counting from right of `dirs' output # pushd -N: start counting from right of `dirs' output
switch-to-dir () { switch-to-dir () {
[[ ${#dirstack} -eq 0 ]] && return setopt localoptions nopushdminus
[[ ${#dirstack} -eq 0 ]] && return 1
while ! builtin pushd -q $1 &>/dev/null; do while ! builtin pushd -q $1 &>/dev/null; do
# We found a missing directory: pop it out of the dir stack # We found a missing directory: pop it out of the dir stack
builtin popd -q $1 builtin popd -q $1
# Stop trying if there are no more directories in the dir stack # Stop trying if there are no more directories in the dir stack
[[ ${#dirstack} -eq 0 ]] && break [[ ${#dirstack} -eq 0 ]] && return 1
done done
} }
insert-cycledleft () { insert-cycledleft () {
emulate -L zsh switch-to-dir +1 || return
setopt nopushdminus
switch-to-dir +1 local fn
for fn (chpwd $chpwd_functions precmd $precmd_functions); do
(( $+functions[$fn] )) && $fn
done
zle reset-prompt zle reset-prompt
} }
zle -N insert-cycledleft zle -N insert-cycledleft
insert-cycledright () { insert-cycledright () {
emulate -L zsh switch-to-dir -0 || return
setopt nopushdminus
switch-to-dir -0 local fn
for fn (chpwd $chpwd_functions precmd $precmd_functions); do
(( $+functions[$fn] )) && $fn
done
zle reset-prompt zle reset-prompt
} }
zle -N insert-cycledright zle -N insert-cycledright
......
# Dirhistory plugin
This plugin adds keyboard shortcuts for navigating directory history and hierarchy.
To use it, add `dirhistory` to the plugins array in your zshrc file:
```zsh
plugins=(... dirhistory)
```
## Keyboard Shortcuts
| Shortcut | Description |
|-----------------------------------|-----------------------------------------------------------|
| <kbd>alt</kbd> + <kbd>left</kbd> | Go to previous directory |
| <kbd>alt</kbd> + <kbd>right</kbd> | Undo <kbd>alt</kbd> + <kbd>left</kbd> |
| <kbd>alt</kbd> + <kbd>up</kbd> | Move into the parent directory |
| <kbd>alt</kbd> + <kbd>down</kbd> | Move into the first child directory by alphabetical order |
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
# Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories # Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. # that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
# #
# Navigate directory hierarchy using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented)
# ALT-UP moves to higher hierarchy (cd ..)
# ALT-DOWN moves into the first directory found in alphabetical order
#
dirhistory_past=($PWD) dirhistory_past=($PWD)
dirhistory_future=() dirhistory_future=()
...@@ -119,6 +123,10 @@ zle -N dirhistory_zle_dirhistory_back ...@@ -119,6 +123,10 @@ zle -N dirhistory_zle_dirhistory_back
# xterm in normal mode # xterm in normal mode
bindkey "\e[3D" dirhistory_zle_dirhistory_back bindkey "\e[3D" dirhistory_zle_dirhistory_back
bindkey "\e[1;3D" dirhistory_zle_dirhistory_back bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
# Mac teminal (alt+left/right)
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[b" dirhistory_zle_dirhistory_back
fi
# Putty: # Putty:
bindkey "\e\e[D" dirhistory_zle_dirhistory_back bindkey "\e\e[D" dirhistory_zle_dirhistory_back
# GNU screen: # GNU screen:
...@@ -127,7 +135,56 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back ...@@ -127,7 +135,56 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back
zle -N dirhistory_zle_dirhistory_future zle -N dirhistory_zle_dirhistory_future
bindkey "\e[3C" dirhistory_zle_dirhistory_future bindkey "\e[3C" dirhistory_zle_dirhistory_future
bindkey "\e[1;3C" dirhistory_zle_dirhistory_future bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[f" dirhistory_zle_dirhistory_future
fi
bindkey "\e\e[C" dirhistory_zle_dirhistory_future bindkey "\e\e[C" dirhistory_zle_dirhistory_future
bindkey "\eO3C" dirhistory_zle_dirhistory_future bindkey "\eO3C" dirhistory_zle_dirhistory_future
#
# HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings
#
# Move up in hierarchy
function dirhistory_up() {
cd .. || return 1
}
# Move down in hierarchy
function dirhistory_down() {
cd "$(find . -mindepth 1 -maxdepth 1 -type d | sort -n | head -n 1)" || return 1
}
# Bind keys to hierarchy navigation
function dirhistory_zle_dirhistory_up() {
zle kill-buffer # Erase current line in buffer
dirhistory_up
zle accept-line
}
function dirhistory_zle_dirhistory_down() {
zle kill-buffer # Erase current line in buffer
dirhistory_down
zle accept-line
}
zle -N dirhistory_zle_dirhistory_up
# xterm in normal mode
bindkey "\e[3A" dirhistory_zle_dirhistory_up
bindkey "\e[1;3A" dirhistory_zle_dirhistory_up
# Mac teminal (alt+up)
#bindkey "^[?" dirhistory_zle_dirhistory_up #dont know it
# Putty:
bindkey "\e\e[A" dirhistory_zle_dirhistory_up
# GNU screen:
bindkey "\eO3A" dirhistory_zle_dirhistory_up
zle -N dirhistory_zle_dirhistory_down
bindkey "\e[3B" dirhistory_zle_dirhistory_down
bindkey "\e[1;3B" dirhistory_zle_dirhistory_down
# Mac teminal (alt+down)
#bindkey "^[?" dirhistory_zle_dirhistory_down #dont know it
bindkey "\e\e[B" dirhistory_zle_dirhistory_down
bindkey "\eO3B" dirhistory_zle_dirhistory_down
# Dirpersist plugin
This plugin keeps a running tally of the previous 20 unique directories in the $HOME/.zdirs file. When you cd to a new directory, it is prepended to the beginning of the file.
To use it, add `dirpersist` to the plugins array in your zshrc file:
```zsh
plugins=(... dirpersist)
```
# Django plugin
This plugin adds completion and hints for the [Django Project](https://www.djangoproject.com/) `manage.py` commands
and options.
To use it, add `django` to the plugins array in your zshrc file:
```zsh
plugins=(... django)
```
## Usage
```zsh
$> python manage.py (press <TAB> here)
```
Would result in:
```zsh
cleanup -- remove old data from the database
compilemessages -- compile .po files to .mo for use with gettext
createcachetable -- creates table for SQL cache backend
createsuperuser -- create a superuser
dbshell -- run command-line client for the current database
diffsettings -- display differences between the current settings and Django defaults
dumpdata -- output contents of database as a fixture
flush -- execute 'sqlflush' on the current database
inspectdb -- output Django model module for tables in database
loaddata -- install the named fixture(s) in the database
makemessages -- pull out all strings marked for translation
reset -- executes 'sqlreset' for the given app(s)
runfcgi -- run this project as a fastcgi
runserver -- start a lightweight web server for development
...
```
If you want to see the options available for a specific command, try:
```zsh
$> python manage.py makemessages (press <TAB> here)
```
And that would result in:
```zsh
--all -a -- re-examine all code and templates
--domain -d -- domain of the message files (default: "django")
--extensions -e -- file extension(s) to examine (default: ".html")
--help -- display help information
--locale -l -- locale to process (default: all)
--pythonpath -- directory to add to the Python path
--settings -- python path to settings module
...
```
...@@ -349,6 +349,7 @@ _managepy-commands() { ...@@ -349,6 +349,7 @@ _managepy-commands() {
'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,' 'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,'
'runserver:Starts a lightweight Web server for development.' 'runserver:Starts a lightweight Web server for development.'
'shell:Runs a Python interactive interpreter.' 'shell:Runs a Python interactive interpreter.'
'showmigrations:Shows all available migrations for the current project.'
'sql:Prints the CREATE TABLE SQL statements for the given app name(s).' 'sql:Prints the CREATE TABLE SQL statements for the given app name(s).'
'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).' 'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).'
'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).' 'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).'
......
File mode changed from 100755 to 100644
# Docker-compose plugin for oh my zsh # Docker-compose
A copy of the completion script from the [docker-compose](https://github.com/docker/compose/blob/master/contrib/completion/zsh/_docker-compose) git repo. This plugin provides completion for [docker-compose](https://docs.docker.com/compose/) as well as some
aliases for frequent docker-compose commands.
To use it, add docker-compose to the plugins array of your zshrc file:
```
plugins=(... docker-compose)
```
## Aliases
| Alias | Command | Description |
|-----------|--------------------------|------------------------------------------------------------------|
| dco | `docker-compose` | Docker-compose main command |
| dcb | `docker-compose build` | Build containers |
| dce | `docker-compose exec` | Execute command inside a container |
| dcps | `docker-compose ps` | List containers |
| dcrestart | `docker-compose restart` | Restart container |
| dcrm | `docker-compose rm` | Remove container |
| dcr | `docker-compose run` | Run a command in container |
| dcstop | `docker-compose stop` | Stop a container |
| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service |
| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon |
| dcdn | `docker-compose down` | Stop and remove containers |
| dcl | `docker-compose logs` | Show logs of container |
| dclf | `docker-compose logs -f` | Show logs and follow output |
| dcpull | `docker-compose pull` | Pull image of a service |
| dcstart | `docker-compose start` | Start a container |
...@@ -3,11 +3,6 @@ ...@@ -3,11 +3,6 @@
# Description # Description
# ----------- # -----------
# zsh completion for docker-compose # zsh completion for docker-compose
# https://github.com/sdurrheimer/docker-compose-zsh-completion
# -------------------------------------------------------------------------
# Version
# -------
# 1.5.0
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Authors # Authors
# ------- # -------
...@@ -199,7 +194,9 @@ __docker-compose_subcommand() { ...@@ -199,7 +194,9 @@ __docker-compose_subcommand() {
(build) (build)
_arguments \ _arguments \
$opts_help \ $opts_help \
"*--build-arg=[Set build-time variables for one service.]:<varname>=<value>: " \
'--force-rm[Always remove intermediate containers.]' \ '--force-rm[Always remove intermediate containers.]' \
'--memory[Memory limit for the build container.]' \
'--no-cache[Do not use cache when building the image.]' \ '--no-cache[Do not use cache when building the image.]' \
'--pull[Always attempt to pull a newer version of the image.]' \ '--pull[Always attempt to pull a newer version of the image.]' \
'*:services:__docker-compose_services_from_build' && ret=0 '*:services:__docker-compose_services_from_build' && ret=0
...@@ -207,13 +204,16 @@ __docker-compose_subcommand() { ...@@ -207,13 +204,16 @@ __docker-compose_subcommand() {
(bundle) (bundle)
_arguments \ _arguments \
$opts_help \ $opts_help \
'--push-images[Automatically push images for any services which have a `build` option specified.]' \
'(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to "<project name>.dab".]:file:_files' && ret=0 '(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to "<project name>.dab".]:file:_files' && ret=0
;; ;;
(config) (config)
_arguments \ _arguments \
$opts_help \ $opts_help \
'(--quiet -q)'{--quiet,-q}"[Only validate the configuration, don't print anything.]" \ '(--quiet -q)'{--quiet,-q}"[Only validate the configuration, don't print anything.]" \
'--services[Print the service names, one per line.]' && ret=0 '--resolve-image-digests[Pin image tags to digests.]' \
'--services[Print the service names, one per line.]' \
'--volumes[Print the volume names, one per line.]' && ret=0
;; ;;
(create) (create)
_arguments \ _arguments \
...@@ -242,7 +242,7 @@ __docker-compose_subcommand() { ...@@ -242,7 +242,7 @@ __docker-compose_subcommand() {
$opts_help \ $opts_help \
'-d[Detached mode: Run command in the background.]' \ '-d[Detached mode: Run command in the background.]' \
'--privileged[Give extended privileges to the process.]' \ '--privileged[Give extended privileges to the process.]' \
'--user=[Run the command as this user.]:username:_users' \ '(-u --user)'{-u,--user=}'[Run the command as this user.]:username:_users' \
'-T[Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY.]' \ '-T[Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY.]' \
'--index=[Index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \ '--index=[Index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \
'(-):running services:__docker-compose_runningservices' \ '(-):running services:__docker-compose_runningservices' \
...@@ -252,6 +252,12 @@ __docker-compose_subcommand() { ...@@ -252,6 +252,12 @@ __docker-compose_subcommand() {
(help) (help)
_arguments ':subcommand:__docker-compose_commands' && ret=0 _arguments ':subcommand:__docker-compose_commands' && ret=0
;; ;;
(images)
_arguments \
$opts_help \
'-q[Only display IDs]' \
'*:services:__docker-compose_services_all' && ret=0
;;
(kill) (kill)
_arguments \ _arguments \
$opts_help \ $opts_help \
...@@ -308,16 +314,17 @@ __docker-compose_subcommand() { ...@@ -308,16 +314,17 @@ __docker-compose_subcommand() {
(run) (run)
_arguments \ _arguments \
$opts_help \ $opts_help \
$opts_no_deps \
'-d[Detached mode: Run container in the background, print new container name.]' \ '-d[Detached mode: Run container in the background, print new container name.]' \
'*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \ '*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
'--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \ '--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \
'--name=[Assign a name to the container]:name: ' \ '--name=[Assign a name to the container]:name: ' \
$opts_no_deps \
'(-p --publish)'{-p,--publish=}"[Publish a container's port(s) to the host]" \ '(-p --publish)'{-p,--publish=}"[Publish a container's port(s) to the host]" \
'--rm[Remove container after run. Ignored in detached mode.]' \ '--rm[Remove container after run. Ignored in detached mode.]' \
"--service-ports[Run command with the service's ports enabled and mapped to the host.]" \ "--service-ports[Run command with the service's ports enabled and mapped to the host.]" \
'-T[Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY.]' \ '-T[Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY.]' \
'(-u --user)'{-u,--user=}'[Run as specified username or uid]:username or uid:_users' \ '(-u --user)'{-u,--user=}'[Run as specified username or uid]:username or uid:_users' \
'(-v --volume)*'{-v,--volume=}'[Bind mount a volume]:volume: ' \
'(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \ '(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \
'(-):services:__docker-compose_services' \ '(-):services:__docker-compose_services' \
'(-):command: _command_names -e' \ '(-):command: _command_names -e' \
...@@ -340,6 +347,11 @@ __docker-compose_subcommand() { ...@@ -340,6 +347,11 @@ __docker-compose_subcommand() {
$opts_timeout \ $opts_timeout \
'*:running services:__docker-compose_runningservices' && ret=0 '*:running services:__docker-compose_runningservices' && ret=0
;; ;;
(top)
_arguments \
$opts_help \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(unpause) (unpause)
_arguments \ _arguments \
$opts_help \ $opts_help \
...@@ -385,9 +397,17 @@ _docker-compose() { ...@@ -385,9 +397,17 @@ _docker-compose() {
integer ret=1 integer ret=1
typeset -A opt_args typeset -A opt_args
local file_description
if [[ -n ${words[(r)-f]} || -n ${words[(r)--file]} ]] ; then
file_description="Specify an override docker-compose file (default: docker-compose.override.yml)"
else
file_description="Specify an alternate docker-compose file (default: docker-compose.yml)"
fi
_arguments -C \ _arguments -C \
'(- :)'{-h,--help}'[Get help]' \ '(- :)'{-h,--help}'[Get help]' \
'(-f --file)'{-f,--file}'[Specify an alternate docker-compose file (default: docker-compose.yml)]:file:_files -g "*.yml"' \ '*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \ '(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
'--verbose[Show more output]' \ '--verbose[Show more output]' \
'(- :)'{-v,--version}'[Print version and exit]' \ '(- :)'{-v,--version}'[Print version and exit]' \
......
...@@ -18,6 +18,9 @@ alias dcrm='docker-compose rm' ...@@ -18,6 +18,9 @@ alias dcrm='docker-compose rm'
alias dcr='docker-compose run' alias dcr='docker-compose run'
alias dcstop='docker-compose stop' alias dcstop='docker-compose stop'
alias dcup='docker-compose up' alias dcup='docker-compose up'
alias dcupd='docker-compose up -d'
alias dcdn='docker-compose down' alias dcdn='docker-compose down'
alias dcl='docker-compose logs' alias dcl='docker-compose logs'
alias dclf='docker-compose logs -f' alias dclf='docker-compose logs -f'
alias dcpull='docker-compose pull'
alias dcstart='docker-compose start'
This diff is collapsed.
#compdef docker dockerd #compdef docker dockerd
# #
# zsh completion for docker (http://docker.com) # zsh completion for docker (https://docker.com)
# #
# version: 0.3.0 # version: 0.3.0
# github: https://github.com/felixr/docker-zsh-completion # github: https://github.com/felixr/docker-zsh-completion
...@@ -226,7 +226,7 @@ __docker_get_log_options() { ...@@ -226,7 +226,7 @@ __docker_get_log_options() {
common_options=("max-buffer-size" "mode") common_options=("max-buffer-size" "mode")
common_options2=("env" "env-regex" "labels") common_options2=("env" "env-regex" "labels")
awslogs_options=($common_options "awslogs-create-group" "awslogs-datetime-format" "awslogs-group" "awslogs-multiline-pattern" "awslogs-region" "awslogs-stream" "tag") awslogs_options=($common_options "awslogs-create-group" "awslogs-datetime-format" "awslogs-group" "awslogs-multiline-pattern" "awslogs-region" "awslogs-stream" "tag")
fluentd_options=($common_options $common_options2 "fluentd-address" "fluentd-async-connect" "fluentd-buffer-limit" "fluentd-retry-wait" "fluentd-max-retries" "tag") fluentd_options=($common_options $common_options2 "fluentd-address" "fluentd-async-connect" "fluentd-buffer-limit" "fluentd-retry-wait" "fluentd-max-retries" "fluentd-sub-second-precision" "tag")
gcplogs_options=($common_options $common_options2 "gcp-log-cmd" "gcp-meta-id" "gcp-meta-name" "gcp-meta-zone" "gcp-project") gcplogs_options=($common_options $common_options2 "gcp-log-cmd" "gcp-meta-id" "gcp-meta-name" "gcp-meta-zone" "gcp-project")
gelf_options=($common_options $common_options2 "gelf-address" "gelf-compression-level" "gelf-compression-type" "tag") gelf_options=($common_options $common_options2 "gelf-address" "gelf-compression-level" "gelf-compression-type" "tag")
journald_options=($common_options $common_options2 "tag") journald_options=($common_options $common_options2 "tag")
...@@ -431,7 +431,7 @@ __docker_complete_events_filter() { ...@@ -431,7 +431,7 @@ __docker_complete_events_filter() {
integer ret=1 integer ret=1
declare -a opts declare -a opts
opts=('container' 'daemon' 'event' 'image' 'label' 'network' 'type' 'volume') opts=('container' 'daemon' 'event' 'image' 'label' 'network' 'scope' 'type' 'volume')
if compset -P '*='; then if compset -P '*='; then
case "${${words[-1]%=*}#*=}" in case "${${words[-1]%=*}#*=}" in
...@@ -450,9 +450,9 @@ __docker_complete_events_filter() { ...@@ -450,9 +450,9 @@ __docker_complete_events_filter() {
;; ;;
(event) (event)
local -a event_opts local -a event_opts
event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach' event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disable' 'disconnect' 'enable' 'exec_create' 'exec_detach'
'exec_start' 'export' 'health_status' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' 'exec_start' 'export' 'health_status' 'import' 'install' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'remove' 'rename' 'resize'
'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update') 'restart' 'save' 'start' 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update')
_describe -t event-filter-opts "event filter options" event_opts && ret=0 _describe -t event-filter-opts "event filter options" event_opts && ret=0
;; ;;
(image) (image)
...@@ -461,6 +461,11 @@ __docker_complete_events_filter() { ...@@ -461,6 +461,11 @@ __docker_complete_events_filter() {
(network) (network)
__docker_complete_networks && ret=0 __docker_complete_networks && ret=0
;; ;;
(scope)
local -a scope_opts
scope_opts=('local' 'swarm')
_describe -t scope-filter-opts "scope filter options" scope_opts && ret=0
;;
(type) (type)
local -a type_opts local -a type_opts
type_opts=('container' 'daemon' 'image' 'network' 'volume') type_opts=('container' 'daemon' 'image' 'network' 'volume')
...@@ -745,6 +750,7 @@ __docker_container_subcommand() { ...@@ -745,6 +750,7 @@ __docker_container_subcommand() {
"($help)--privileged[Give extended Linux capabilities to the command]" \ "($help)--privileged[Give extended Linux capabilities to the command]" \
"($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \ "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \
"($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" \ "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" \
"($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories" \
"($help -):containers:__docker_complete_running_containers" \ "($help -):containers:__docker_complete_running_containers" \
"($help -)*::command:->anycommand" && ret=0 "($help -)*::command:->anycommand" && ret=0
case $state in case $state in
...@@ -888,7 +894,7 @@ __docker_container_subcommand() { ...@@ -888,7 +894,7 @@ __docker_container_subcommand() {
$opts_help \ $opts_help \
$opts_attach_exec_run_start \ $opts_attach_exec_run_start \
"($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \ "($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \
"($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \ "($help -i --interactive)"{-i,--interactive}"[Attach container's stdin]" \
"($help -)*:containers:__docker_complete_stopped_containers" && ret=0 "($help -)*:containers:__docker_complete_stopped_containers" && ret=0
;; ;;
(stats) (stats)
...@@ -922,7 +928,7 @@ __docker_container_subcommand() { ...@@ -922,7 +928,7 @@ __docker_container_subcommand() {
local state local state
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
opts_create_run_update \ $opts_create_run_update \
"($help -)*: :->values" && ret=0 "($help -)*: :->values" && ret=0
case $state in case $state in
(values) (values)
...@@ -1393,7 +1399,7 @@ __docker_nodes() { ...@@ -1393,7 +1399,7 @@ __docker_nodes() {
# Names # Names
if [[ $type = (names|all) ]]; then if [[ $type = (names|all) ]]; then
for line in $lines; do for line in $lines; do
s="${line[${begin[NAME]},${end[NAME]}]%% ##}" s="${line[${begin[HOSTNAME]},${end[HOSTNAME]}]%% ##}"
nodes=($nodes $s) nodes=($nodes $s)
done done
fi fi
...@@ -1955,6 +1961,7 @@ __docker_service_subcommand() { ...@@ -1955,6 +1961,7 @@ __docker_service_subcommand() {
"($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)" "($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)"
"($help)--health-timeout=[Maximum time to allow one check to run]:time: " "($help)--health-timeout=[Maximum time to allow one check to run]:time: "
"($help)--hostname=[Service container hostname]:hostname: " \ "($help)--hostname=[Service container hostname]:hostname: " \
"($help)--isolation=[Service container isolation mode]:isolation:(default process hyperv)" \
"($help)*--label=[Service labels]:label: " "($help)*--label=[Service labels]:label: "
"($help)--limit-cpu=[Limit CPUs]:value: " "($help)--limit-cpu=[Limit CPUs]:value: "
"($help)--limit-memory=[Limit Memory]:value: " "($help)--limit-memory=[Limit Memory]:value: "
...@@ -2168,9 +2175,9 @@ __docker_stacks() { ...@@ -2168,9 +2175,9 @@ __docker_stacks() {
end[${header[$i,$((j-1))]}]=-1 end[${header[$i,$((j-1))]}]=-1
lines=(${lines[2,-1]}) lines=(${lines[2,-1]})
# Service ID # Service NAME
for line in $lines; do for line in $lines; do
s="${line[${begin[ID]},${end[ID]}]%% ##}" s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
stacks=($stacks $s) stacks=($stacks $s)
done done
...@@ -2631,7 +2638,6 @@ __docker_subcommand() { ...@@ -2631,7 +2638,6 @@ __docker_subcommand() {
"($help)--default-gateway-v6[Container default gateway IPv6 address]:IPv6 address: " \ "($help)--default-gateway-v6[Container default gateway IPv6 address]:IPv6 address: " \
"($help)--default-shm-size=[Default shm size for containers]:size:" \ "($help)--default-shm-size=[Default shm size for containers]:size:" \
"($help)*--default-ulimit=[Default ulimits for containers]:ulimit: " \ "($help)*--default-ulimit=[Default ulimits for containers]:ulimit: " \
"($help)--disable-legacy-registry[Disable contacting legacy registries (default true)]" \
"($help)*--dns=[DNS server to use]:DNS: " \ "($help)*--dns=[DNS server to use]:DNS: " \
"($help)*--dns-opt=[DNS options to use]:DNS option: " \ "($help)*--dns-opt=[DNS options to use]:DNS option: " \
"($help)*--dns-search=[DNS search domains to use]:DNS search: " \ "($help)*--dns-search=[DNS search domains to use]:DNS search: " \
......
# Doctl
This plugin provides completion for [Doctl](https://github.com/digitalocean/doctl).
To use it add doctl to the plugins array in your zshrc file.
```bash
plugins=(... doctl)
```
# Autocompletion for doctl, the command line tool for DigitalOcean service
#
# doctl project: https://github.com/digitalocean/doctl
#
# Author: https://github.com/HalisCz
if [ $commands[doctl] ]; then
source <(doctl completion zsh)
fi
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment