diff options
Diffstat (limited to 'plugins/gh')
-rw-r--r-- | plugins/gh/gh.plugin.zsh | 17 |
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 |