From 53d6febd20e9dc7013ec75a0ae69a1e828be6b45 Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Thu, 9 Jun 2022 21:45:23 -0400 Subject: [PATCH] Add docker completions for zsh --- chezmoi/dot_zshrc.d/executable_docker.zsh | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 chezmoi/dot_zshrc.d/executable_docker.zsh diff --git a/chezmoi/dot_zshrc.d/executable_docker.zsh b/chezmoi/dot_zshrc.d/executable_docker.zsh new file mode 100644 index 0000000..8723380 --- /dev/null +++ b/chezmoi/dot_zshrc.d/executable_docker.zsh @@ -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" +)