From 936b47940b0169bf219fffc476418a2b7f43200b Mon Sep 17 00:00:00 2001 From: Juan Barbat Date: Wed, 21 Oct 2026 10:04:22 -0300 Subject: [PATCH] fix(fish): restore the Linux tool PATH lost in #68, one list for every host #68 branched before #60-#62 and its 10-core.fish overwrote their Linux PATH block and the macOS-only open alias. Hosts kept older copies and each edited its own directory list. Restore both with the union of every host's dirs (each added only if it exists) so all hosts share one file. Run the w7/w8 fish tests in CI. Refs #69 --- .github/workflows/ci.yml | 2 ++ fish/conf.d/10-core.fish | 15 ++++++++++- fish/tests/w8-linux-path.fish | 51 +++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 fish/tests/w8-linux-path.fish diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ffa252..41cab9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,6 +65,8 @@ jobs: fish fish/tests/w5a-hremote.fish fish fish/tests/w5b-herdr-ssh.fish fish fish/tests/w6-agent-helpers.fish + fish fish/tests/w7-gentle-ai-path.fish + fish fish/tests/w8-linux-path.fish - name: Validate JSON configs shell: bash diff --git a/fish/conf.d/10-core.fish b/fish/conf.d/10-core.fish index 1392862..42657b2 100644 --- a/fish/conf.d/10-core.fish +++ b/fish/conf.d/10-core.fish @@ -49,6 +49,16 @@ else end set -gx VISUAL "$EDITOR" +if test (uname) = Linux + # One list for every Linux host; each dir is added only if it exists. + # Later entries end up first (fish_add_path --move prepends). + for tool_bin in /usr/local/go/bin $HOME/.local/go-*/bin "$HOME/.bun/bin" "$HOME/.local/share/pnpm/bin" /nix/var/nix/profiles/default/bin "$HOME/.nix-profile/bin" "$HOME/.opencode/bin" "$HOME/.local/bin" + if test -d "$tool_bin" + fish_add_path --path --move "$tool_bin" + end + end +end + alias g git alias ga 'git add' alias gc 'git commit -m' @@ -64,7 +74,10 @@ alias .. 'cd ..' alias ... 'cd ../..' alias .... 'cd ../../..' alias c clear -alias o open + +if test (uname) = Darwin + alias o open +end if command -q eza alias ll 'eza -la --icons --git' diff --git a/fish/tests/w8-linux-path.fish b/fish/tests/w8-linux-path.fish new file mode 100644 index 0000000..478f3e7 --- /dev/null +++ b/fish/tests/w8-linux-path.fish @@ -0,0 +1,51 @@ +#!/usr/bin/env fish +# Linux hosts share one 10-core.fish: every tool directory any host uses is +# listed once and added only when it exists, so no host edits its own copy. +# macOS keeps the `o` alias; Linux has no `open`, so the alias is absent. + +set -l repo_root (cd (dirname (dirname (status filename))); and pwd) +set -l core "$repo_root/conf.d/10-core.fish" +set -l fish_bin (status fish-path) +set -l ws (mktemp -d) + +function fail + printf 'FAIL: %s\n' "$argv" >&2 + exit 1 +end + +set -l home "$ws/home" +set -l fake "$ws/fake" +mkdir -p "$fake" +printf '#!/bin/sh\necho Linux\n' >"$fake/uname" +chmod +x "$fake/uname" + +# Prefixed with $home so the test never depends on the runner's real dirs. +set -l dirs .local/go-1.27.1/bin .bun/bin .local/share/pnpm/bin .nix-profile/bin .opencode/bin .local/bin +for d in $dirs + mkdir -p "$home/$d" +end + +set -l probe 'source $argv[1]; string join "|" $PATH; functions -q o; and echo o=defined; or echo o=absent' +set -l out (env -i HOME="$home" PATH="$fake:/usr/bin:/bin" "$fish_bin" --no-config -c "$probe" "$core") + +# fish_add_path --move prepends in loop order: the last listed dir ends first. +# Only entries under the fake HOME: system dirs like /nix differ per runner. +set -l ours (string join '|' (string match -- "$home/*" (string split '|' -- $out[1]))) +set -l expected "$home/.local/bin|$home/.opencode/bin|$home/.nix-profile/bin|$home/.local/share/pnpm/bin|$home/.bun/bin|$home/.local/go-1.27.1/bin" +test "$ours" = "$expected"; or fail "Linux PATH order (expected $expected, got $ours)" +string match -q -- "$home/.local/bin|*" "$out[1]"; or fail "user-local bin must lead PATH ($out[1])" +test "$out[2]" = o=absent; or fail "Linux must not define the macOS open alias ($out[2])" + +# Absent dirs are skipped, not added. +set -l bare "$ws/bare" +mkdir -p "$bare" +set -l out_bare (env -i HOME="$bare" PATH="$fake:/usr/bin:/bin" "$fish_bin" --no-config -c "$probe" "$core") +string match -q -- "*$bare*" "$out_bare[1]"; and fail "missing dirs were added to PATH: $out_bare[1]" + +# macOS keeps `o`. +printf '#!/bin/sh\necho Darwin\n' >"$fake/uname" +set -l out_mac (env -i HOME="$bare" PATH="$fake:/usr/bin:/bin" "$fish_bin" --no-config -c "$probe" "$core") +test "$out_mac[2]" = o=defined; or fail "macOS must define the open alias ($out_mac[2])" + +rm -rf -- "$ws" +printf 'linux path checks passed\n'