Skip to content

Commit 481b756

Browse files
authored
Merge pull request #1049 from github/devm33/install-path
Update install script to handle post install path updates better
2 parents 3fa6453 + 24a3d00 commit 481b756

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

install.sh

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,34 @@ chmod +x "$INSTALL_DIR/copilot"
122122
echo "✓ GitHub Copilot CLI installed to $INSTALL_DIR/copilot"
123123
rm -rf "$TMP_DIR"
124124

125-
# Check if install directory is in PATH
126-
case ":$PATH:" in
127-
*":$INSTALL_DIR:"*) ;;
128-
*)
125+
# Check if installed binary is accessible
126+
if ! command -v copilot >/dev/null 2>&1; then
127+
echo ""
128+
echo "Notice: $INSTALL_DIR is not in your PATH"
129+
130+
# Detect shell rc file
131+
case "$(basename "${SHELL:-/bin/sh}")" in
132+
zsh) RC_FILE="$HOME/.zshrc" ;;
133+
bash) RC_FILE="$HOME/.bashrc" ;;
134+
*) RC_FILE="$HOME/.profile" ;;
135+
esac
136+
137+
# Prompt user to add to shell rc file (only if interactive)
138+
if [ -t 0 ] || [ -e /dev/tty ]; then
129139
echo ""
130-
echo "Warning: $INSTALL_DIR is not in your PATH"
131-
echo "Add it to your PATH by adding this line to your shell profile:"
132-
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
133-
;;
134-
esac
140+
printf "Would you like to add it to %s? [y/N] " "$RC_FILE"
141+
if read -r REPLY </dev/tty 2>/dev/null; then
142+
if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then
143+
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$RC_FILE"
144+
echo "✓ Added PATH export to $RC_FILE"
145+
fi
146+
fi
147+
else
148+
echo ""
149+
echo "To add $INSTALL_DIR to your PATH permanently, add this to $RC_FILE:"
150+
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
151+
fi
152+
fi
135153

136154
echo ""
137155
echo "Installation complete! Run 'copilot help' to get started."

0 commit comments

Comments
 (0)