Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ echo "Downloading from: $DOWNLOAD_URL"

# Download and extract with error handling
TMP_DIR="$(mktemp -d)"
trap 'rm -rf -- "$TMP_DIR"' EXIT
TMP_TARBALL="$TMP_DIR/copilot-${PLATFORM}-${ARCH}.tar.gz"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "${CURL_AUTH[@]}" "$DOWNLOAD_URL" -o "$TMP_TARBALL"
elif command -v wget >/dev/null 2>&1; then
wget -qO "$TMP_TARBALL" "${WGET_AUTH[@]}" "$DOWNLOAD_URL"
else
echo "Error: Neither curl nor wget found. Please install one of them."
rm -rf "$TMP_DIR"
exit 1
fi

Expand All @@ -101,15 +101,13 @@ if [ "$CHECKSUMS_AVAILABLE" = true ]; then
echo "✓ Checksum validated"
else
echo "Error: Checksum validation failed." >&2
rm -rf "$TMP_DIR"
exit 1
fi
elif command -v shasum >/dev/null 2>&1; then
if (cd "$TMP_DIR" && shasum -a 256 -c --ignore-missing SHA256SUMS.txt >/dev/null 2>&1); then
echo "✓ Checksum validated"
else
echo "Error: Checksum validation failed." >&2
rm -rf "$TMP_DIR"
exit 1
fi
else
Expand All @@ -120,7 +118,6 @@ fi
# Check that the file is a valid tarball
if ! tar -tzf "$TMP_TARBALL" >/dev/null 2>&1; then
echo "Error: Downloaded file is not a valid tarball or is corrupted." >&2
rm -rf "$TMP_DIR"
exit 1
fi

Expand All @@ -144,15 +141,15 @@ fi
tar -xz -C "$INSTALL_DIR" -f "$TMP_TARBALL"
chmod +x "$INSTALL_DIR/copilot"
echo "✓ GitHub Copilot CLI installed to $INSTALL_DIR/copilot"
rm -rf "$TMP_DIR"

# Check if installed binary is accessible
if ! command -v copilot >/dev/null 2>&1; then
echo ""
echo "Notice: $INSTALL_DIR is not in your PATH"

# Detect shell profile file for PATH
case "$(basename "${SHELL:-/bin/sh}")" in
CURRENT_SHELL="$(basename "${SHELL:-/bin/sh}")"
case "$CURRENT_SHELL" in
zsh) RC_FILE="${ZDOTDIR:-$HOME}/.zprofile" ;;
bash)
if [ -f "$HOME/.bash_profile" ]; then
Expand All @@ -163,29 +160,36 @@ if ! command -v copilot >/dev/null 2>&1; then
RC_FILE="$HOME/.profile"
fi
;;
fish) RC_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/fish/conf.d/copilot.fish" ;;
*) RC_FILE="$HOME/.profile" ;;
esac

PATH_LINE="export PATH=\"$INSTALL_DIR:\$PATH\""
if [ "$CURRENT_SHELL" = "fish" ]; then
PATH_LINE="fish_add_path \"$INSTALL_DIR\""
fi

# Prompt user to add to shell rc file (only if interactive)
if [ -t 0 ] || [ -e /dev/tty ]; then
echo ""
printf "Would you like to add it to %s? [y/N] " "$RC_FILE"
if read -r REPLY </dev/tty 2>/dev/null; then
if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$RC_FILE"
echo "✓ Added PATH export to $RC_FILE"
mkdir -p "$(dirname "$RC_FILE")"
echo "$PATH_LINE" >> "$RC_FILE"
echo "✓ Added PATH configuration to $RC_FILE"
echo " Restart your shell or run: source $RC_FILE"
fi
fi
else
echo ""
echo "To add $INSTALL_DIR to your PATH permanently, add this to $RC_FILE:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
echo " $PATH_LINE"
fi

echo ""
echo "Installation complete! To get started, run:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\" && copilot help"
echo " $PATH_LINE && copilot help"
else
echo ""
echo "Installation complete! Run 'copilot help' to get started."
Expand Down