Add docker completions for zsh
This commit is contained in:
parent
8cdc4cb25b
commit
53d6febd20
1 changed files with 26 additions and 0 deletions
26
chezmoi/dot_zshrc.d/executable_docker.zsh
Normal file
26
chezmoi/dot_zshrc.d/executable_docker.zsh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/zsh
|
||||
|
||||
(
|
||||
set -euo pipefail
|
||||
|
||||
if ! command -v docker &> /dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
zstyle ':completion:*:*:docker:*' option-stacking yes
|
||||
zstyle ':completion:*:*:docker-*:*' option-stacking yes
|
||||
|
||||
DOCKER_COMPLETION_FILE="${ZSH_COMPLETIONS_DIR}/_docker"
|
||||
|
||||
if [ -r "$DOCKER_COMPLETION_FILE" ]; then
|
||||
zstat -H COMPLETION_FILE_STAT "$DOCKER_COMPLETION_FILE"
|
||||
zstat -H DOCKER_FILE_STAT "$(command -v docker)"
|
||||
|
||||
if [ "${COMPLETION_FILE_STAT[ctime]}" -ge "${DOCKER_FILE_STAT[ctime]}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
curl -LSsf https://raw.githubusercontent.com/docker/cli/master/contrib/completion/zsh/_docker -o "$DOCKER_COMPLETION_FILE"
|
||||
chmod +x "$DOCKER_COMPLETION_FILE"
|
||||
)
|
Loading…
Reference in a new issue