Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,41 @@ If you have access to GitHub Copilot via your organization or enterprise, you ca

### Installation

Install globally with npm:
Install with [WinGet](https://github.com/microsoft/winget-cli) (Windows):

```bash
npm install -g @github/copilot
winget install GitHub.Copilot
```

Install with [Homebrew](https://formulae.brew.sh/cask/copilot-cli):
Install with [Homebrew](https://formulae.brew.sh/cask/copilot-cli) (macOS and Linux):

```bash
brew install copilot-cli
```

Install with [WinGet](https://github.com/microsoft/winget-cli):
Install with the install script (macOS and Linux):

```bash
winget install GitHub.Copilot
curl -fsSL https://gh.io/copilot-install | bash
```

Or

```bash
wget -qO- https://gh.io/copilot-install | bash
```

Install with [npm](https://www.npmjs.com/package/@github/copilot) (macOS, Linux, and Windows):

```bash
npm install -g @github/copilot
```

Use `| sudo bash` to run as root and install to `/usr/local/bin`.

Set `PREFIX` to install to `$PREFIX/bin/` directory. Defaults to `/usr/local`
when run as root or `$HOME/.local` when run as a non-root user.
Comment thread
devm33 marked this conversation as resolved.

### Launching the CLI

```bash
Expand Down
92 changes: 92 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env bash
set -e

# GitHub Copilot CLI Installation Script
# Usage: curl -fsSL https://gh.io/copilot-install | bash
# or: wget -qO- https://gh.io/copilot-install | bash
# Use | sudo bash to run as root and install to /usr/local/bin
# Export PREFIX to install to $PREFIX/bin/ directory (default: /usr/local for
# root, $HOME/.local for non-root), e.g., export PREFIX=$HOME/custom to install
# to $HOME/custom/bin

echo "Installing GitHub Copilot CLI..."

# Detect platform
case "$(uname -s || echo "")" in
Darwin*) PLATFORM="darwin" ;;
Linux*) PLATFORM="linux" ;;
*)
if command -v winget >/dev/null 2>&1; then
echo "Windows detected. Installing via winget..."
winget install GitHub.Copilot
exit $?
else
echo "Error: Windows detected but winget not found. Please see https://gh.io/install-copilot-readme" >&2
exit 1
fi
;;
esac

# Detect architecture
case "$(uname -m)" in
x86_64|amd64) ARCH="x64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) echo "Error: Unsupported architecture $(uname -m)" >&2 ; exit 1 ;;
esac

DOWNLOAD_URL="https://github.com/github/copilot-cli/releases/latest/download/copilot-${PLATFORM}-${ARCH}.tar.gz"
echo "Downloading from: $DOWNLOAD_URL"

# Download and extract with error handling
TMP_TARBALL="$(mktemp)"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$DOWNLOAD_URL" -o "$TMP_TARBALL"
elif command -v wget >/dev/null 2>&1; then
wget -qO "$TMP_TARBALL" "$DOWNLOAD_URL"
else
echo "Error: Neither curl nor wget found. Please install one of them."
Comment thread
devm33 marked this conversation as resolved.
exit 1
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 -f "$TMP_TARBALL"
exit 1
fi

# Check if running as root, fallback to non-root
if [ "$(id -u 2>/dev/null || echo 1)" -eq 0 ]; then
Comment thread
devm33 marked this conversation as resolved.
PREFIX="${PREFIX:-/usr/local}"
else
PREFIX="${PREFIX:-$HOME/.local}"
Comment thread
devm33 marked this conversation as resolved.
fi
Comment thread
devm33 marked this conversation as resolved.
INSTALL_DIR="$PREFIX/bin"
if ! mkdir -p "$INSTALL_DIR"; then
echo "Error: Could not create directory $INSTALL_DIR. You may not have write permissions." >&2
echo "Try running this script with sudo or set PREFIX to a directory you own (e.g., export PREFIX=\$HOME/.local)." >&2
exit 1
fi

# Install binary
if [ -f "$INSTALL_DIR/copilot" ]; then
echo "Notice: Replacing copilot binary found at $INSTALL_DIR/copilot."
fi
tar -xz -C "$INSTALL_DIR" -f "$TMP_TARBALL"
chmod +x "$INSTALL_DIR/copilot"
echo "✓ GitHub Copilot CLI installed to $INSTALL_DIR/copilot"
rm -f "$TMP_TARBALL"

# Check if install directory is in PATH
case ":$PATH:" in
*":$INSTALL_DIR:"*) ;;
*)
echo ""
echo "Warning: $INSTALL_DIR is not in your PATH"
echo "Add it to your PATH by adding this line to your shell profile:"
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
;;
esac

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