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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion fish/conf.d/10-core.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
51 changes: 51 additions & 0 deletions fish/tests/w8-linux-path.fish
Original file line number Diff line number Diff line change
@@ -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'
Loading