From dbba8515093338ede2a834ea64f3c02cfcf1868a Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Mon, 20 Jun 2022 19:51:21 -0400 Subject: [PATCH] Add copilot completions --- chezmoi/dot_zshrc.d/executable_copilot.zsh | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 chezmoi/dot_zshrc.d/executable_copilot.zsh diff --git a/chezmoi/dot_zshrc.d/executable_copilot.zsh b/chezmoi/dot_zshrc.d/executable_copilot.zsh new file mode 100644 index 0000000..cf7d202 --- /dev/null +++ b/chezmoi/dot_zshrc.d/executable_copilot.zsh @@ -0,0 +1,23 @@ +#!/usr/bin/zsh + +( + set -euo pipefail + + if ! command -v copilot &> /dev/null; then + exit 0 + fi + + COPILOT_COMPLETION_PATH="${ZSH_COMPLETIONS_DIR}/_copilot" + + if [ -r "$COPILOT_COMPLETION_PATH" ]; then + zstat -H COMPLETION_FILE_STAT "$COPILOT_COMPLETION_PATH" + zstat -H COPILOT_FILE_STAT "$(command -v copilot)" + + if [ "${COMPLETION_FILE_STAT[ctime]}" -ge "${COPILOT_FILE_STAT[ctime]}" ]; then + exit 0 + fi + fi + + copilot completion zsh > "$COPILOT_COMPLETION_PATH" + chmod +x "$COPILOT_COMPLETION_PATH" +)