diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/bin/eza_aarch64-unknown-linux-gnu b/bin/eza_aarch64-unknown-linux-gnu new file mode 100755 index 0000000..b8d8bd3 Binary files /dev/null and b/bin/eza_aarch64-unknown-linux-gnu differ diff --git a/bin/eza b/bin/eza_x86_64-unknown-linux-gnu similarity index 100% rename from bin/eza rename to bin/eza_x86_64-unknown-linux-gnu diff --git a/bin/eza_x86_64-unknown-linux-musl b/bin/eza_x86_64-unknown-linux-musl new file mode 100755 index 0000000..0d40b22 Binary files /dev/null and b/bin/eza_x86_64-unknown-linux-musl differ diff --git a/bin/fish-4.2.1-linux-aarch64 b/bin/fish-4.2.1-linux-aarch64 new file mode 100755 index 0000000..c738e81 Binary files /dev/null and b/bin/fish-4.2.1-linux-aarch64 differ diff --git a/bin/fish b/bin/fish-4.2.1-linux-x86_64 similarity index 100% rename from bin/fish rename to bin/fish-4.2.1-linux-x86_64 diff --git a/fish/add-on.fish b/fish/add-on.fish index 2a34961..de8457e 100644 --- a/fish/add-on.fish +++ b/fish/add-on.fish @@ -1,10 +1,38 @@ ## 替换 ls 默认行为 function ls --description 'alias ls to eza if possible' - if type -q ~/.flinty/bin/eza - ~/.flinty/bin/eza -la --icons $argv - else - command ls -la $argv + # 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 ## 更新配置