Skip to content

Commit 1190c65

Browse files
authored
Add installation script
1 parent 44a9767 commit 1190c65

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

install.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# GitHub Copilot CLI Installation Script
5+
# Usage: curl -fsSL https://gh.io/copilot-install | bash
6+
# or: wget -qO- https://gh.io/copilot-install | bash
7+
8+
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
9+
10+
echo "Installing GitHub Copilot CLI..."
11+
12+
# Detect platform
13+
case "$(uname -s)" in
14+
Darwin*) PLATFORM="darwin" ;;
15+
Linux*) PLATFORM="linux" ;;
16+
*) echo "Error: Unsupported platform $(uname -s). For Windows, recommend using: winget install GitHub.Copilot" >&2 ; exit 1 ;;
17+
esac
18+
19+
# Detect architecture
20+
case "$(uname -m)" in
21+
x86_64|amd64) ARCH="x64" ;;
22+
aarch64|arm64) ARCH="arm64" ;;
23+
*) echo "Error: Unsupported architecture $(uname -m)" >&2 ; exit 1 ;;
24+
esac
25+
26+
DOWNLOAD_URL="https://github.com/github/copilot-cli/releases/latest/download/copilot-${PLATFORM}-${ARCH}.tar.gz"
27+
echo "Downloading from: $DOWNLOAD_URL"
28+
29+
DOWNLOAD_DIR="${HOME}/.copilot/"
30+
mkdir -p "$DOWNLOAD_DIR"
31+
32+
# Download and extract
33+
cd "$DOWNLOAD_DIR"
34+
if command -v curl >/dev/null 2>&1; then
35+
curl -fsSL "$DOWNLOAD_URL" | tar -xz
36+
elif command -v wget >/dev/null 2>&1; then
37+
wget -qO- "$DOWNLOAD_URL" | tar -xz
38+
else
39+
echo "Error: Neither curl nor wget found. Please install one of them."
40+
exit 1
41+
fi
42+
43+
if [ "$(id -u 2>/dev/null || echo 1)" -eq 0 ]; then
44+
PREFIX="${PREFIX:-/usr/local}"
45+
else
46+
PREFIX="${PREFIX:-$HOME/.local}"
47+
mkdir -p "$INSTALL_DIR/bin"
48+
fi
49+
INSTALL_DIR="$PREFIX/bin"
50+
51+
# Install binary
52+
if [ -f "copilot" ]; then
53+
mv copilot "$INSTALL_DIR/copilot"
54+
chmod +x "$INSTALL_DIR/copilot"
55+
echo "✓ GitHub Copilot CLI installed to $INSTALL_DIR/copilot"
56+
else
57+
echo "Error: copilot binary not found in tarball"
58+
exit 1
59+
fi
60+
61+
# Check if install directory is in PATH
62+
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
63+
echo ""
64+
echo "Warning: $INSTALL_DIR is not in your PATH"
65+
echo "Add it to your PATH by adding this line to your shell profile:"
66+
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
67+
fi
68+
69+
echo ""
70+
echo "Installation complete! Run 'copilot help' to get started."

0 commit comments

Comments
 (0)