Compare commits

...
Author SHA1 Message Date
Robby Russell b20d95c390 fix(gh): preserve valid completion cache on failure 2026-09-26 19:00:22 -05:00
2 changed files with 10 additions and 2 deletions
+2
View File
@@ -18,3 +18,5 @@ plugin is loaded, which is usually when you start up a new terminal emulator.
The cache is stored at: The cache is stored at:
- `$ZSH_CACHE_DIR/completions/_gh` completions script - `$ZSH_CACHE_DIR/completions/_gh` completions script
If an update fails, the last successfully generated completion script is kept.
+8 -2
View File
@@ -13,6 +13,12 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_gh" local completion_file="$ZSH_CACHE_DIR/completions/_gh"
zf_mv -f -- =( gh completion --shell zsh ) "$TMPPREFIX" local completion_tmp="${completion_file}.$$.${RANDOM}"
if gh completion --shell zsh >| "$completion_tmp" && [[ -s "$completion_tmp" ]]; then
zf_mv -f -- "$completion_tmp" "$completion_file"
fi
command rm -f -- "$completion_tmp"
} &| } &|