mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-15 01:48:34 -07:00
fix(docker): only generate completion for docker >23 (#11754)
This commit is contained in:
parent
68f3ebb4de
commit
6bffaab290
@ -1,13 +1,3 @@
|
||||
# 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.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _docker
|
||||
_comps[docker]=_docker
|
||||
fi
|
||||
|
||||
docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker" &|
|
||||
|
||||
alias dbl='docker build'
|
||||
alias dcin='docker container inspect'
|
||||
alias dcls='docker container ls'
|
||||
@ -41,3 +31,22 @@ alias dvls='docker volume ls'
|
||||
alias dvprune='docker volume prune'
|
||||
alias dxc='docker container exec'
|
||||
alias dxcit='docker container exec -it'
|
||||
|
||||
if (( ! $+commands[docker] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
{
|
||||
# `docker completion` is only available from 23.0.0 on
|
||||
local _docker_version=$(docker version --format '{{.Client.Version}}' 2>/dev/null)
|
||||
if is-at-least 23.0.0 $_docker_version; then
|
||||
# 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.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _docker
|
||||
_comps[docker]=_docker
|
||||
fi
|
||||
docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
|
||||
fi
|
||||
} &|
|
||||
|
Loading…
Reference in New Issue
Block a user