From cd95a21c8774fbf2fe0e0f2c5b8d7afa84e59420 Mon Sep 17 00:00:00 2001 From: FlintyLemming Date: Fri, 19 Dec 2025 14:13:57 +0800 Subject: [PATCH] add fish config --- fish/add-on.fish | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fish/add-on.fish b/fish/add-on.fish index 98c5a68..61d480f 100644 --- a/fish/add-on.fish +++ b/fish/add-on.fish @@ -55,21 +55,24 @@ function restore_cursor --on-event fish_postexec end # 自动化 Locale 修复逻辑 修复例如 nano 无法输入中文的问题 -# 1. 如果 locale 命令报错(说明配置非法) -# 2. 或者 LC_ALL 为空且处于 C 环境(说明环境太原始) -if not locale >/dev/null 2>&1; or test -z "$LC_ALL" -a (string match -ri '^C' "$LANG") +# 1. 如果 locale 命令执行报错 +# 2. 或者 (LC_ALL 为空 并且 LANG 以 C 开头) +if not locale >/dev/null 2>&1 + or begin + test -z "$LC_ALL" + and string match -qi "C*" "$LANG" + end - # 优先检测并使用 C.UTF-8 (现代 GNU 系统标准) - if locale -a | string match -q "C.utf8" + # 开始修复 + if locale -a | string match -qi "C.utf8" set -gx LANG C.UTF-8 set -gx LC_ALL C.UTF-8 - # 备选:en_US.UTF-8 (传统 Linux 标准) else if locale -a | string match -qi "en_US.utf8" set -gx LANG en_US.UTF-8 set -gx LC_ALL en_US.UTF-8 end - # 强制清理可能存在的非法变量(如你之前的 LC_CTYPE=UTF-8) + # 清理非法的 LC_CTYPE set -e LC_CTYPE end