## 替换 ls 默认行为 function ls --description 'alias ls to eza if possible' # 1. 优先使用系统安装的 eza (PATH 里的) if type -q eza eza -la --icons $argv return end # 2. 如果系统没有,尝试根据架构寻找 ~/.flinty/bin 下的二进制文件 set -l arch (uname -m) set -l target_bin "" set -l bin_path "$HOME/.flinty/bin" switch $arch case x86_64 # 如果是 Alpine Linux,通常需要用 musl 版本 (根据你提供的文件名) if test -f /etc/alpine-release set target_bin "eza_x86_64-unknown-linux-musl" else set target_bin "eza_x86_64-unknown-linux-gnu" end case aarch64 arm64 set target_bin "eza_aarch64-unknown-linux-gnu" end set -l custom_eza "$bin_path/$target_bin" # 3. 检查文件是否存在且可执行 if test -n "$target_bin"; and test -x "$custom_eza" $custom_eza -la --icons $argv return end # 4. 既没有系统 eza 也没有本地二进制,回退到 command ls command ls -la $argv end ## 更新配置 function dotu set -l current_dir (pwd) cd $HOME/.flinty if git pull source ~/.config/fish/config.fish echo "Config reloaded successfully!" end # 回到原位 cd $current_dir end ## 修复光标消失 function restore_cursor --on-event fish_postexec tput cnorm 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") # 优先检测并使用 C.UTF-8 (现代 GNU 系统标准) if locale -a | string match -q "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) set -e LC_CTYPE end abbr -a port 'sudo ss -tulnp | grep' abbr -a process 'ps aux | grep'