summaryrefslogtreecommitdiff
path: root/plugins/gh
diff options
context:
space:
mode:
authorMarc Cornellà <hello@mcornella.com>2021-09-15 18:18:25 +0200
committerMarc Cornellà <hello@mcornella.com>2021-09-15 18:18:25 +0200
commit4e6e49652b69557c01ef1ce81c96da7eb9b34e6e (patch)
tree70f6f8f2610a60636d5f8b9acf5c3b784a1631b2 /plugins/gh
parentc21ff38b8fda0584208ffd697dac0502e2327466 (diff)
downloadzsh-4e6e49652b69557c01ef1ce81c96da7eb9b34e6e.tar.gz
zsh-4e6e49652b69557c01ef1ce81c96da7eb9b34e6e.tar.bz2
zsh-4e6e49652b69557c01ef1ce81c96da7eb9b34e6e.zip
fix(plugins): fix `_comps` error in completion generation plugins (#10190)
Fixes #10190
Diffstat (limited to 'plugins/gh')
-rw-r--r--plugins/gh/gh.plugin.zsh17
1 files changed, 11 insertions, 6 deletions
diff --git a/plugins/gh/gh.plugin.zsh b/plugins/gh/gh.plugin.zsh
index 8e055ec35..c3d87848d 100644
--- a/plugins/gh/gh.plugin.zsh
+++ b/plugins/gh/gh.plugin.zsh
@@ -1,13 +1,18 @@
# Autocompletion for the GitHub CLI (gh).
-
if (( $+commands[gh] )); then
- if [[ ! -r "$ZSH_CACHE_DIR/gh_version" \
- || "$(gh --version)" != "$(< "$ZSH_CACHE_DIR/gh_version")"
- || ! -f "$ZSH/plugins/gh/_gh" ]]; then
- gh completion --shell zsh > $ZSH/plugins/gh/_gh
- gh --version > $ZSH_CACHE_DIR/gh_version
+ ver="$(gh --version)"
+ ver_file="$ZSH_CACHE_DIR/gh_version"
+ comp_file="$ZSH/plugins/gh/_gh"
+
+ if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
+ gh completion --shell zsh >| "$comp_file"
+ echo "$ver" >| "$ver_file"
fi
+
+ declare -A _comps
autoload -Uz _gh
_comps[gh]=_gh
+
+ unset ver ver_file comp_file
fi