mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-11-11 11:11:50 -05:00
perf(mise): regenerate completion only when stale (#13759)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
if (( $+commands[mise] )); then
|
if (( $+commands[mise] )); then
|
||||||
_mise_bin=mise
|
_mise_bin=$commands[mise]
|
||||||
elif [[ -x ~/.local/bin/mise ]]; then
|
elif [[ -x ~/.local/bin/mise ]]; then
|
||||||
_mise_bin=~/.local/bin/mise
|
_mise_bin=~/.local/bin/mise
|
||||||
else
|
else
|
||||||
@@ -8,7 +8,6 @@ fi
|
|||||||
|
|
||||||
# Load mise hooks
|
# Load mise hooks
|
||||||
eval "$($_mise_bin activate zsh)"
|
eval "$($_mise_bin activate zsh)"
|
||||||
unset _mise_bin
|
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `mise`. Otherwise, compinit will have already done that.
|
# bind it to `mise`. Otherwise, compinit will have already done that.
|
||||||
@@ -18,9 +17,13 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_mise" ]]; then
|
|||||||
_comps[mise]=_mise
|
_comps[mise]=_mise
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate and load mise completion
|
# Generate completion only when missing/empty or stale relative to the mise binary.
|
||||||
zmodload -F zsh/files b:zf_mv
|
if [[ ! -s "$ZSH_CACHE_DIR/completions/_mise" || "$_mise_bin" -nt "$ZSH_CACHE_DIR/completions/_mise" ]]; then
|
||||||
() {
|
zmodload -F zsh/files b:zf_mv
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._mise"
|
() {
|
||||||
zf_mv -f -- =( mise completion zsh ) "$ZSH_CACHE_DIR/completions/_mise"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._mise"
|
||||||
} &|
|
zf_mv -f -- =( "$_mise_bin" completion zsh ) "$ZSH_CACHE_DIR/completions/_mise"
|
||||||
|
} &|
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset _mise_bin
|
||||||
|
|||||||
Reference in New Issue
Block a user