Add docker completions for zsh

This commit is contained in:
Tony Blyler 2022-06-09 21:45:23 -04:00
parent 8cdc4cb25b
commit 53d6febd20
Signed by: tblyler
GPG key ID: 7F13D9A60C0D678E

View 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"
)