Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions fish/conf.d/10-core.fish
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ else
end
set -gx VISUAL "$EDITOR"

if test (uname) = Darwin
# This file owns the macOS PATH; config.fish must not edit it, because it
# loads after conf.d and would bury the entries below (and gentle-ai's).
for brew_bin in /opt/homebrew/bin/brew /usr/local/bin/brew
if test -x $brew_bin
$brew_bin shellenv fish | source
break
end
end
# Later entries end up first (fish_add_path --move prepends).
for tool_bin in /usr/local/bin /nix/var/nix/profiles/default/bin "$HOME/.nix-profile/bin" "$HOME/.bun/bin" "$HOME/.volta/bin" "$HOME/.opencode/bin" "$HOME/.local/bin" /opt/homebrew/sbin /opt/homebrew/bin "$HOME/.cargo/bin"
if test -d "$tool_bin"
fish_add_path --path --move "$tool_bin"
end
end
end

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).
Expand Down
4 changes: 4 additions & 0 deletions fish/tests/w2-core.fish
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ set -l aliases (run_fish -c 'functions gpl' | string collect)
string match -q '*git pull*' "$aliases"; or fail 'gpl alias'
run_fish -c 'functions -q gs; and exit 1; or exit 0'; or fail 'gs alias should not exist'

# Platform PATH blocks (w8) would put the host's real Homebrew starship ahead of
# this stub; pin a platform with no Homebrew so only the guard is under test.
printf '#!/bin/sh\necho Linux\n' >"$bin/uname"
chmod +x "$bin/uname"
printf '#!/bin/sh\n[ "$1" = init ] && printf "set -gx W2_STARSHIP_READY 1\\n"\n' >"$bin/starship"
chmod +x "$bin/starship"
set -l noninteractive (run_fish -c 'set -q W2_STARSHIP_READY; and echo ready; or echo skipped')
Expand Down
13 changes: 11 additions & 2 deletions fish/tests/w8-linux-path.fish
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,19 @@ 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`.
# macOS: 10-core.fish owns PATH too (config.fish no longer edits it).
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")
set -l mac "$ws/mac"
set -l mac_dirs .cargo/bin .local/bin .opencode/bin .volta/bin .bun/bin .nix-profile/bin .gentle-ai/bin
for d in $mac_dirs
mkdir -p "$mac/$d"
end
set -l out_mac (env -i HOME="$mac" 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])"
set -l mac_ours (string join '|' (string match -- "$mac/*" (string split '|' -- $out_mac[1])))
set -l mac_expected "$mac/.gentle-ai/bin|$mac/.cargo/bin|$mac/.local/bin|$mac/.opencode/bin|$mac/.volta/bin|$mac/.bun/bin|$mac/.nix-profile/bin"
test "$mac_ours" = "$mac_expected"; or fail "macOS PATH order (expected $mac_expected, got $mac_ours)"
string match -q -- "$mac/.gentle-ai/bin|*" "$out_mac[1]"; or fail "gentle-ai launchers must lead the macOS PATH ($out_mac[1])"

rm -rf -- "$ws"
printf 'linux path checks passed\n'
Loading