mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-25 01:43:04 +01:00
feat(cli): add omz diagnose locale check (#14140)
* feat(core): add `omz diagnose` locale check Reports whether the runtime locale is UTF-8, using the CODESET parameter of the zsh/langinfo module that lib/functions.zsh already loads at startup, with a `locale charmap` fallback when the module is unavailable. Non-UTF-8 charsets cause completion glitches such as duplicated characters at the prompt. This replaces the startup warning proposed in the earlier iteration: per maintainer feedback the check belongs in `omz diagnose` so that no shell startup cost is paid and it only surfaces when the user is already debugging their setup. I used AI to draft and rework this change. * docs: document omz diagnose in README Add a Diagnostics section below the update instructions describing `omz diagnose` and pointing at `omz_diagnostic_dump` for full reports. I used AI to draft this change.
This commit is contained in:
1 parent
49a6348eac
commit
109270911c
2 files changed
+39
No files matched your search
@@ -552,6 +552,20 @@ omz update
|
||||
|
||||
Magic! 🎉
|
||||
|
||||
## Diagnostics
|
||||
|
||||
If something looks off (glitched characters, completions misbehaving), run:
|
||||
|
||||
```sh
|
||||
omz diagnose
|
||||
```
|
||||
|
||||
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
|
||||
(see the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)).
|
||||
|
||||
For a full report suitable for attaching to a bug report, use `omz_diagnostic_dump`.
|
||||
|
||||
## Uninstalling Oh My Zsh
|
||||
|
||||
Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup.
|
||||
|
||||
+25
@@ -24,6 +24,7 @@ function _omz {
|
||||
local -a cmds subcmds
|
||||
cmds=(
|
||||
'changelog:Print the changelog'
|
||||
'diagnose:Run configuration diagnostics'
|
||||
'help:Usage information'
|
||||
'plugin:Manage plugins'
|
||||
'pr:Manage Oh My Zsh Pull Requests'
|
||||
@@ -176,12 +177,36 @@ function _omz::log {
|
||||
|
||||
## User-facing commands
|
||||
|
||||
function _omz::diagnose {
|
||||
# Check the runtime locale: non-UTF-8 charsets are known to cause glitches
|
||||
# such as duplicated characters at the prompt after completions.
|
||||
# https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command
|
||||
#
|
||||
# `lib/functions.zsh` loads the zsh/langinfo module at startup, so the
|
||||
# CODESET parameter is already available without any subprocess; only fall
|
||||
# back to `locale charmap` when that module is unavailable (zsh built without it).
|
||||
local codeset="${langinfo[CODESET]:-}"
|
||||
if [[ -z "$codeset" ]] && (( $+commands[locale] )); then
|
||||
codeset="$(locale charmap 2>/dev/null)"
|
||||
fi
|
||||
|
||||
if [[ "${codeset:l}" = (utf-8|utf8) ]]; then
|
||||
_omz::log info "locale charmap is UTF-8"
|
||||
else
|
||||
_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 "consider setting a UTF-8 locale, e.g.: export LANG=C.UTF-8"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function _omz::help {
|
||||
cat >&2 <<EOF
|
||||
Usage: omz <command> [options]
|
||||
|
||||
Available commands:
|
||||
|
||||
diagnose Run configuration diagnostics
|
||||
help Print this help message
|
||||
changelog Print the changelog
|
||||
plugin <command> Manage plugins
|
||||
|
||||
Reference in new issue
Block a user