Skip to content

install: add fish shell support for PATH configuration#2381

Merged
devm33 merged 1 commit intogithub:mainfrom
marcelsafin:fix/install-fish-shell-path
Mar 29, 2026
Merged

install: add fish shell support for PATH configuration#2381
devm33 merged 1 commit intogithub:mainfrom
marcelsafin:fix/install-fish-shell-path

Conversation

@marcelsafin
Copy link
Copy Markdown
Contributor

Fish shell users currently fall into the catch-all *) case in the shell profile detection, which writes POSIX export syntax to ~/.profile. This silently does nothing because:

  1. Fish does not source ~/.profile
  2. Fish does not use export PATH="...:$PATH" syntax (PATH is an array in fish, not colon-separated)
  3. The get-started hint export PATH="..." && copilot help fails in a fish session

This adds a fish) case alongside the existing zsh) and bash) cases, using the idiomatic config path and command:

  • Config file: ${XDG_CONFIG_HOME:-$HOME/.config}/fish/conf.d/copilot.fish (auto-sourced by fish)
  • PATH command: fish_add_path (available since fish 3.2, released March 2021)

The three places that previously hardcoded export PATH=... now use a PATH_LINE variable, so the shell-specific logic lives in one place rather than being duplicated across the interactive prompt, non-interactive hint, and get-started instructions.

Before (fish user):

Would you like to add it to /home/user/.profile? [y/N] y
✓ Added PATH export to /home/user/.profile    ← fish never reads this
  export PATH="/home/user/.local/bin:$PATH" && copilot help    ← fails in fish

After (fish user):

Would you like to add it to /home/user/.config/fish/conf.d/copilot.fish? [y/N] y
✓ Added PATH export to /home/user/.config/fish/conf.d/copilot.fish
  fish_add_path "/home/user/.local/bin" && copilot help

No change in behavior for bash, zsh, or other POSIX shells.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class fish shell handling to the installer’s PATH configuration logic so fish users get a fish-compatible PATH command and the correct config file path.

Changes:

  • Detects fish as a distinct shell and targets ~/.config/fish/conf.d/copilot.fish (or $XDG_CONFIG_HOME equivalent).
  • Centralizes the shell-specific PATH command into a PATH_LINE variable used for interactive edits and printed hints.
  • Updates the installer’s non-interactive and “get started” messages to use PATH_LINE instead of hardcoded export PATH=....

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

RC_FILE="$HOME/.profile"
fi
;;
fish) RC_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/fish/conf.d/copilot.fish" ;;
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the fish case, RC_FILE points into ${XDG_CONFIG_HOME:-$HOME/.config}/fish/conf.d/, which may not exist. Appending with >> "$RC_FILE" will fail with “No such file or directory”. Consider creating the parent directory (e.g., mkdir -p "$(dirname "$RC_FILE")") before writing or before printing instructions that reference this path.

Copilot uses AI. Check for mistakes.
Fish shell users currently fall into the catch-all case, which writes
POSIX export syntax to ~/.profile. Fish does not source ~/.profile and
does not use export PATH="...:$PATH" syntax, so the PATH addition
silently does nothing.

Add a fish case that targets the idiomatic conf.d directory and uses
fish_add_path, matching how the script already handles zsh and bash
with their respective profile files and syntax. Extract the PATH
command into a variable to avoid duplicating the shell-specific logic
across the interactive prompt, non-interactive hint, and get-started
instructions.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@devm33 devm33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again!

@devm33 devm33 merged commit 9c1a0ae into github:main Mar 29, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants