Skip to content

Commit 07af0bc

Browse files
committed
install: add fish shell support for PATH configuration
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.
1 parent b175fd8 commit 07af0bc

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

install.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ if ! command -v copilot >/dev/null 2>&1; then
152152
echo "Notice: $INSTALL_DIR is not in your PATH"
153153

154154
# Detect shell profile file for PATH
155-
case "$(basename "${SHELL:-/bin/sh}")" in
155+
CURRENT_SHELL="$(basename "${SHELL:-/bin/sh}")"
156+
case "$CURRENT_SHELL" in
156157
zsh) RC_FILE="${ZDOTDIR:-$HOME}/.zprofile" ;;
157158
bash)
158159
if [ -f "$HOME/.bash_profile" ]; then
@@ -163,29 +164,36 @@ if ! command -v copilot >/dev/null 2>&1; then
163164
RC_FILE="$HOME/.profile"
164165
fi
165166
;;
167+
fish) RC_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/fish/conf.d/copilot.fish" ;;
166168
*) RC_FILE="$HOME/.profile" ;;
167169
esac
168170

171+
PATH_LINE="export PATH=\"$INSTALL_DIR:\$PATH\""
172+
if [ "$CURRENT_SHELL" = "fish" ]; then
173+
PATH_LINE="fish_add_path \"$INSTALL_DIR\""
174+
fi
175+
169176
# Prompt user to add to shell rc file (only if interactive)
170177
if [ -t 0 ] || [ -e /dev/tty ]; then
171178
echo ""
172179
printf "Would you like to add it to %s? [y/N] " "$RC_FILE"
173180
if read -r REPLY </dev/tty 2>/dev/null; then
174181
if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then
175-
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$RC_FILE"
176-
echo "✓ Added PATH export to $RC_FILE"
182+
mkdir -p "$(dirname "$RC_FILE")"
183+
echo "$PATH_LINE" >> "$RC_FILE"
184+
echo "✓ Added PATH configuration to $RC_FILE"
177185
echo " Restart your shell or run: source $RC_FILE"
178186
fi
179187
fi
180188
else
181189
echo ""
182190
echo "To add $INSTALL_DIR to your PATH permanently, add this to $RC_FILE:"
183-
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
191+
echo " $PATH_LINE"
184192
fi
185193

186194
echo ""
187195
echo "Installation complete! To get started, run:"
188-
echo " export PATH=\"$INSTALL_DIR:\$PATH\" && copilot help"
196+
echo " $PATH_LINE && copilot help"
189197
else
190198
echo ""
191199
echo "Installation complete! Run 'copilot help' to get started."

0 commit comments

Comments
 (0)