mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-12-04 14:19:04 +01:00
feat(cli): validate the plugins list in omz diagnose (#14306)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
This commit is contained in:
1 parent
5b2db7b495
commit
d7046e0511
2 files changed
+52
-1
No files matched your search
@@ -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`.
|
||||||
|
|
||||||
|
|||||||
@@ -78,14 +78,64 @@ 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
|
||||||
|
|
||||||
|
local plugin base distance candidate suggestion found=0
|
||||||
|
local -a missing
|
||||||
|
for plugin ($plugins); do
|
||||||
|
if is_plugin "$ZSH_CUSTOM" "$plugin" || is_plugin "$ZSH" "$plugin"; then
|
||||||
|
(( ++found ))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
missing+=("$plugin")
|
||||||
|
done
|
||||||
|
|
||||||
|
for plugin ($missing); do
|
||||||
|
suggestion=
|
||||||
|
# Check both roots at each distance, with custom plugins first for ties.
|
||||||
|
for distance in 1 2; do
|
||||||
|
for base in "$ZSH_CUSTOM" "$ZSH"; do
|
||||||
|
for candidate in \
|
||||||
|
"$base"/plugins/(#a$distance)${(b)plugin}(#qN-/); do
|
||||||
|
if is_plugin "$base" "${candidate:t}"; then
|
||||||
|
suggestion=${candidate:t}
|
||||||
|
break 3
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
||||||
|
if [[ -n "$suggestion" ]]; then
|
||||||
|
_omz::log warn "plugin '$plugin' not found (did you mean '$suggestion'?)" \
|
||||||
|
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 {
|
||||||
|
|||||||
Reference in new issue
Block a user