diff --git a/plugins/gh/README.md b/plugins/gh/README.md index 1de7242a3..cc399ef83 100644 --- a/plugins/gh/README.md +++ b/plugins/gh/README.md @@ -18,3 +18,5 @@ plugin is loaded, which is usually when you start up a new terminal emulator. The cache is stored at: - `$ZSH_CACHE_DIR/completions/_gh` completions script + +If an update fails, the last successfully generated completion script is kept. diff --git a/plugins/gh/gh.plugin.zsh b/plugins/gh/gh.plugin.zsh index 17e4aa8e6..37d327a6d 100644 --- a/plugins/gh/gh.plugin.zsh +++ b/plugins/gh/gh.plugin.zsh @@ -14,5 +14,8 @@ fi zmodload -F zsh/files b:zf_mv () { local TMPPREFIX="$ZSH_CACHE_DIR/completions/._gh" - zf_mv -f -- =( gh completion --shell zsh ) "$ZSH_CACHE_DIR/completions/_gh" + () { + gh completion --shell zsh >| "$1" && [[ -s "$1" ]] \ + && zf_mv -f -- "$1" "$ZSH_CACHE_DIR/completions/_gh" + } =(:) || return } &|