Compare commits

...
Author SHA1 Message Date
Robby RussellandClaude Opus 5.5 dd852f0cfc feat(cli): validate the plugins list in omz diagnose
`omz diagnose` now checks each entry in `plugins=(...)` against the plugin
folders in $ZSH_CUSTOM and $ZSH, and suggests the closest plugin name (up to
two typos, via zsh approximate globbing) for any it can't find. It exits
non-zero when a plugin is missing, same as for the locale check.

Startup already prints "plugin 'x' not found", but that line is easy to miss
(or hidden by instant prompts), and it gives no hint about the right name.

Refs #13877

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 15:52:06 -08:00
2 changed files with 44 additions and 1 deletions

No files matched your search

+2 -1
View File
@@ -562,7 +562,8 @@ omz diagnose
It runs a few quick checks and tells you what to fix — for example, it will warn you when It runs a few quick checks and tells you what to fix — for example, it will warn you when
your locale is not UTF-8, which is a common cause of duplicated characters at the prompt your locale is not UTF-8, which is a common cause of duplicated characters at the prompt
(see the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)). (see the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)),
and it validates your `plugins=(...)` list, suggesting the closest name for any plugin it can't find.
For a full report suitable for attaching to a bug report, use `omz_diagnostic_dump`. For a full report suitable for attaching to a bug report, use `omz_diagnostic_dump`.
+42
View File
@@ -190,14 +190,56 @@ function _omz::diagnose {
codeset="$(locale charmap 2>/dev/null)" codeset="$(locale charmap 2>/dev/null)"
fi fi
local ret=0
if [[ "${codeset:l}" = (utf-8|utf8) ]]; then if [[ "${codeset:l}" = (utf-8|utf8) ]]; then
_omz::log info "locale charmap is UTF-8" _omz::log info "locale charmap is UTF-8"
else else
_omz::log warn "your locale is not UTF-8 (charmap: ${codeset:-unknown})" _omz::log warn "your locale is not UTF-8 (charmap: ${codeset:-unknown})"
_omz::log info "non-UTF-8 locales may cause glitches in completions and international characters" _omz::log info "non-UTF-8 locales may cause glitches in completions and international characters"
_omz::log info "consider setting a UTF-8 locale, e.g.: export LANG=C.UTF-8" _omz::log info "consider setting a UTF-8 locale, e.g.: export LANG=C.UTF-8"
ret=1
fi
_omz::diagnose::plugins || ret=1
return $ret
}
function _omz::diagnose::plugins {
# Validate the plugins array: flag entries with no matching plugin folder,
# and suggest the closest plugin name (up to 2 typos) for each one.
setopt localoptions extendedglob nullglob
local plugin base found=0
local -a missing guesses
for plugin ($plugins); do
if [[ -f "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh" || -f "$ZSH_CUSTOM/plugins/$plugin/_$plugin" \
|| -f "$ZSH/plugins/$plugin/$plugin.plugin.zsh" || -f "$ZSH/plugins/$plugin/_$plugin" ]]; then
(( ++found ))
continue
fi
missing+=("$plugin")
done
for plugin ($missing); do
guesses=()
for base ("$ZSH_CUSTOM/plugins" "$ZSH/plugins"); do
guesses+=("$base"/(#a1)${(b)plugin}(/:t) "$base"/(#a2)${(b)plugin}(/:t))
done
guesses=(${guesses:#$plugin})
if (( $#guesses )); then
_omz::log warn "plugin '$plugin' not found (did you mean '${guesses[1]}'?)" omz::diagnose
else
_omz::log warn "plugin '$plugin' not found" omz::diagnose
fi
done
if (( $#missing )); then
_omz::log info "$found of ${#plugins} plugins found" omz::diagnose
return 1 return 1
fi fi
(( $#plugins )) && _omz::log info "all ${#plugins} plugins found" omz::diagnose
return 0
} }
function _omz::help { function _omz::help {