add fish config

This commit is contained in:
FlintyLemming
2025-12-22 16:43:46 +08:00
parent 4c1f6a7bcf
commit fa6e44189c

View File

@@ -101,16 +101,17 @@ function restore_cursor --on-event fish_postexec
tput cnorm tput cnorm
end end
# 自动化 Locale 修复逻辑 修复例如 nano 无法输入中文的问题 # 自动化 Locale 修复:强制开启 UTF-8 支持并保持英文界面
# 1. 如果 locale 命令执行报错 # 解决 nano, vim 等工具无法输入/显示中文的问题
# 2. 或者 (LC_ALL 为空 并且 LANG 以 C 开头)
if not locale >/dev/null 2>&1 if not locale >/dev/null 2>&1
or begin or begin
test -z "$LC_ALL" test -z "$LC_ALL"
and string match -qi "C*" "$LANG" and string match -qi "C*" "$LANG"
end end
# 开始修复 # 1. 寻找系统可用的 UTF-8 Locale
# 优先使用 C.UTF-8 (现代 Linux 发行版标准,无需安装)
# 备选 en_US.UTF-8
if locale -a | string match -qi "C.utf8" if locale -a | string match -qi "C.utf8"
set -gx LANG C.UTF-8 set -gx LANG C.UTF-8
set -gx LC_ALL 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 LANG en_US.UTF-8
set -gx LC_ALL en_US.UTF-8 set -gx LC_ALL en_US.UTF-8
end end
# 清理非法的 LC_CTYPE # 2. 彻底清理可能冲突的变量
# 清理 LC_CTYPE 确保其继承 LC_ALL 的 UTF-8 设置
set -e LC_CTYPE set -e LC_CTYPE
# 清理 LANGUAGE 确保 UI 界面回退到 LC_ALL 定义的英文
set -e LANGUAGE
end end
## 让 sudo 能够识别自定义 bin 下的脚本 ## 让 sudo 能够识别自定义 bin 下的脚本