3.2 KiB
| title | aliases | tags | sources | created | updated | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Fish Shell PATH Configuration |
|
|
|
2026-04-15 | 2026-04-15 |
Fish Shell PATH Configuration
Fish shell does not automatically include all standard system directories in PATH. Directories like /usr/local/bin are commonly missing, causing commands that work in bash to fail in Fish with Unknown command.
Key Points
/usr/local/binis not in Fish's default PATH — tools installed there (e.g.,kubectl, Homebrew binaries on older macOS installs) must be added explicitly- Use
fish_add_path /usr/local/binto permanently add a directory — it modifiesfish_user_pathsuniversal variable and persists across sessions set -gx fish_user_paths /usr/local/bin $fish_user_pathsis the older manual equivalent;fish_add_pathis idempotent and preferredspf --fix-config-file(superfile config fix) requires a live TTY and cannot run from a non-interactive context like Claude Code agent- SSH connection aliases belong in Fish functions (
~/.config/fish/functions/) that wrap the underlying~/.ssh/configentries — don't duplicate host/user/key info in Fish
Details
Adding Directories to Fish PATH
# Permanent (recommended) — idempotent, safe to run multiple times
fish_add_path /usr/local/bin
fish_add_path /opt/homebrew/bin # Apple Silicon Homebrew
# One-time session only
set -gx PATH /usr/local/bin $PATH
# Manual permanent (older style)
set -U fish_user_paths /usr/local/bin $fish_user_paths
fish_add_path checks for duplicates, so it's safe to call in config.fish on every startup without path bloat.
Diagnosing "Unknown command" Errors
When a tool is installed but Fish can't find it:
# Find where the binary actually lives
which kubectl # may fail
command -v kubectl
# Check current PATH
echo $PATH
# Find the binary manually
find /usr /opt /home -name kubectl 2>/dev/null
Once found, add the parent directory with fish_add_path.
SSH Aliases as Fish Functions
Wrap SSH connections in named Fish functions rather than duplicating config:
# ~/.config/fish/functions/ssh-optical.fish
function ssh-optical
ssh optical-dev # matches a Host block in ~/.ssh/config
end
~/.ssh/config holds the actual host, user, and identity file. The Fish function is just a convenience alias. This separation means updating the SSH config (e.g., changing a hostname) doesn't require updating Fish functions.
Dotfiles Context (2026-04-15 Setup)
Terminal stack configured to match a specific video guide style:
- Terminal: Kitty
- Shell: Fish + tide prompt
- Editor: Neovim with kanagawa-wave theme
- File manager: superfile (
spf) - Font: Hasklug Nerd Font Mono, size 15
Related Concepts
- wiki/dotfiles/_index — full dotfiles topic index with Kitty, Fish, LazyVim, WezTerm articles
- wiki/concepts/shell-static-deploy-patterns — other shell scripting patterns
Sources
- daily/2026-04-15.md — Fish PATH fix for
kubectl(/usr/local/binnot in PATH), SSH aliases setup, terminal dotfiles configuration