1
0
Fork 0
mirror of synced 2024-06-15 13:31:09 -04:00
zimfw/src/stage2/50_zimfw_check_dumpfile.zsh.erb
Eric Nielsen a434fda508
More accurate check-dumpfile action
by using the `_zim_dumpfile_fpath` variable set by the completion module
[here](33737e8c15/init.zsh (L11))
right before `compinit` is run.
2023-02-03 18:56:16 -05:00

22 lines
975 B
Plaintext

_zimfw_check_dumpfile() {
local zdumpfile zfpath zline
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
if [[ -e ${zdumpfile} ]]; then
if (( ${+_zim_dumpfile_fpath} )); then
local -r zcomps=(${^_zim_dumpfile_fpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
if [[ ${zline[2]} -eq ${#zcomps} && ${zline[4]} == ${ZSH_VERSION} ]]; then
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Already up to date"
else
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b New completion configuration needs to be dumped. Will do %Bclean-dumpfile%b."
_zimfw_clean_dumpfile
fi
else
_zimfw_print -u2 -PR "%F{yellow}<%= warn %>%B${zdumpfile}:%b Unable to check. This only works when the completion module is initialized."
fi
else
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Not found"
fi
_zimfw_print 'Done with check-dumpfile.'
}