From fa6e44189c3c6a7c92e88ebdb2bde45ddb43b745 Mon Sep 17 00:00:00 2001 From: FlintyLemming Date: Mon, 22 Dec 2025 16:43:46 +0800 Subject: [PATCH] add fish config --- fish/add-on.fish | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fish/add-on.fish b/fish/add-on.fish index c044a4b..6cccb22 100644 --- a/fish/add-on.fish +++ b/fish/add-on.fish @@ -101,16 +101,17 @@ function restore_cursor --on-event fish_postexec tput cnorm end -# 自动化 Locale 修复逻辑 修复例如 nano 无法输入中文的问题 -# 1. 如果 locale 命令执行报错 -# 2. 或者 (LC_ALL 为空 并且 LANG 以 C 开头) +# 自动化 Locale 修复:强制开启 UTF-8 支持并保持英文界面 +# 解决 nano, vim 等工具无法输入/显示中文的问题 if not locale >/dev/null 2>&1 or begin test -z "$LC_ALL" and string match -qi "C*" "$LANG" end - # 开始修复 + # 1. 寻找系统可用的 UTF-8 Locale + # 优先使用 C.UTF-8 (现代 Linux 发行版标准,无需安装) + # 备选 en_US.UTF-8 if locale -a | string match -qi "C.utf8" set -gx LANG C.UTF-8 set -gx LC_ALL C.UTF-8 @@ -118,9 +119,12 @@ if not locale >/dev/null 2>&1 set -gx LANG en_US.UTF-8 set -gx LC_ALL en_US.UTF-8 end - - # 清理非法的 LC_CTYPE + + # 2. 彻底清理可能冲突的变量 + # 清理 LC_CTYPE 确保其继承 LC_ALL 的 UTF-8 设置 set -e LC_CTYPE + # 清理 LANGUAGE 确保 UI 界面回退到 LC_ALL 定义的英文 + set -e LANGUAGE end ## 让 sudo 能够识别自定义 bin 下的脚本