mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-16 02:40:08 +00:00
feat(docker): add legacy-completion
option
This commit is contained in:
parent
c4392a4da3
commit
7d5e12500a
2 changed files with 24 additions and 14 deletions
|
@ -30,6 +30,15 @@ file**, but be aware of the side effects:
|
||||||
> zstyle ':completion:*:*:docker-*:*' option-stacking yes
|
> zstyle ':completion:*:*:docker-*:*' option-stacking yes
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
|
### Use old-style completion
|
||||||
|
|
||||||
|
If the current completion does not work well for you, you can enable legacy completion instead with the
|
||||||
|
following setting. See https://github.com/ohmyzsh/ohmyzsh/issues/11789 for more information.
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:docker' legacy-completion yes
|
||||||
|
```
|
||||||
|
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
| Alias | Command | Description |
|
| Alias | Command | Description |
|
||||||
|
@ -58,7 +67,7 @@ file**, but be aware of the side effects:
|
||||||
| drm | `docker container rm` | Remove the specified container(s) |
|
| drm | `docker container rm` | Remove the specified container(s) |
|
||||||
| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) |
|
| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) |
|
||||||
| dst | `docker container start` | Start one or more stopped containers |
|
| dst | `docker container start` | Start one or more stopped containers |
|
||||||
| drs | `docker container restart` | Restart one or more containers
|
| drs | `docker container restart` | Restart one or more containers |
|
||||||
| dsta | `docker stop $(docker ps -q)` | Stop all running containers |
|
| dsta | `docker stop $(docker ps -q)` | Stop all running containers |
|
||||||
| dstp | `docker container stop` | Stop one or more running containers |
|
| dstp | `docker container stop` | Stop one or more running containers |
|
||||||
| dtop | `docker top` | Display the running processes of a container |
|
| dtop | `docker top` | Display the running processes of a container |
|
||||||
|
|
|
@ -41,12 +41,6 @@ fi
|
||||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||||
|
|
||||||
{
|
|
||||||
# docker version returns `Docker version 24.0.2, build cb74dfcd85`
|
|
||||||
# with `s:,:` remove the comma after the version, and select third word of it
|
|
||||||
local _docker_version=${${(s:,:z)"$(command docker --version)"}[3]}
|
|
||||||
# `docker completion` is only available from 23.0.0 on
|
|
||||||
if is-at-least 23.0.0 $_docker_version; then
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `docker`. Otherwise, compinit will have already done that.
|
# bind it to `docker`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
|
||||||
|
@ -54,8 +48,15 @@ fi
|
||||||
autoload -Uz _docker
|
autoload -Uz _docker
|
||||||
_comps[docker]=_docker
|
_comps[docker]=_docker
|
||||||
fi
|
fi
|
||||||
command docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
|
|
||||||
else
|
{
|
||||||
|
# `docker completion` is only available from 23.0.0 on
|
||||||
|
# docker version returns `Docker version 24.0.2, build cb74dfcd85`
|
||||||
|
# with `s:,:` remove the comma after the version, and select third word of it
|
||||||
|
if zstyle -t ':omz:plugins:docker' legacy-completion || \
|
||||||
|
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
||||||
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
||||||
|
else
|
||||||
|
command docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
|
||||||
fi
|
fi
|
||||||
} &|
|
} &|
|
||||||
|
|
Loading…
Reference in a new issue