Skip to content

Commit 9880c60

Browse files
committed
Prompt to add to shell config file
1 parent a949dc9 commit 9880c60

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

install.sh

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,31 @@ rm -rf "$TMP_DIR"
125125
# Check if installed binary is accessible
126126
if ! command -v copilot >/dev/null 2>&1; then
127127
echo ""
128-
echo "Warning: $INSTALL_DIR is not in your PATH"
129-
echo "Add it to your PATH by adding this line to your shell profile:"
130-
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
128+
echo "Notice: $INSTALL_DIR is not in your PATH"
129+
export PATH="$PATH:$INSTALL_DIR"
130+
echo "✓ Added $INSTALL_DIR to PATH for this session"
131+
132+
# Detect shell rc file
133+
case "$(basename "${SHELL:-/bin/sh}")" in
134+
zsh) RC_FILE="$HOME/.zshrc" ;;
135+
bash)
136+
if [ -f "$HOME/.bash_profile" ]; then
137+
RC_FILE="$HOME/.bash_profile"
138+
else
139+
RC_FILE="$HOME/.bashrc"
140+
fi
141+
;;
142+
*) RC_FILE="$HOME/.profile" ;;
143+
esac
144+
145+
# Prompt user to add to shell rc file
146+
echo ""
147+
printf "Would you like to add it to %s? [y/N] " "$RC_FILE"
148+
read -r REPLY </dev/tty
149+
if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then
150+
echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$RC_FILE"
151+
echo "✓ Added PATH export to $RC_FILE"
152+
fi
131153
fi
132154

133155
echo ""

0 commit comments

Comments
 (0)