-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·65 lines (54 loc) · 2.04 KB
/
uninstall.sh
File metadata and controls
executable file
·65 lines (54 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -e
# GitHub Copilot CLI Uninstallation Script
# Usage: curl -fsSL https://gh.io/copilot-uninstall | bash
# or: wget -qO- https://gh.io/copilot-uninstall | bash
# Use | sudo bash to run as root and remove from /usr/local/bin
# Export PREFIX to remove from $PREFIX/bin/ directory (default: /usr/local for
# root, $HOME/.local for non-root), e.g., export PREFIX=$HOME/custom to remove
# from $HOME/custom/bin
echo "Uninstalling GitHub Copilot CLI..."
# Detect platform
case "$(uname -s || echo "")" in
Darwin*|Linux*) ;;
*)
if command -v winget >/dev/null 2>&1; then
echo "Windows detected. Uninstalling via winget..."
winget uninstall GitHub.Copilot
exit $?
else
echo "Error: Windows detected but winget not found. Please remove GitHub Copilot CLI using the package manager you installed it with." >&2
exit 1
fi
;;
esac
# Check if running as root, fallback to non-root
if [ "$(id -u 2>/dev/null || echo 1)" -eq 0 ]; then
PREFIX="${PREFIX:-/usr/local}"
else
PREFIX="${PREFIX:-$HOME/.local}"
fi
INSTALL_DIR="$PREFIX/bin"
TARGET="$INSTALL_DIR/copilot"
if [ ! -e "$TARGET" ]; then
echo "Notice: No copilot binary found at $TARGET."
if command -v copilot >/dev/null 2>&1; then
FOUND_PATH="$(command -v copilot)"
echo "Another copilot binary is still available at $FOUND_PATH."
echo "If you installed it with Homebrew, npm, or another package manager, uninstall it with that tool."
fi
exit 0
fi
if [ ! -w "$TARGET" ] && [ "$(id -u 2>/dev/null || echo 1)" -ne 0 ]; then
echo "Error: Could not remove $TARGET. You may not have write permissions." >&2
echo "Try running this script with sudo or set PREFIX to the installation prefix used previously." >&2
exit 1
fi
rm -f "$TARGET"
echo "✓ Removed $TARGET"
if [ -d "$INSTALL_DIR" ] && [ -z "$(ls -A "$INSTALL_DIR" 2>/dev/null)" ]; then
rmdir "$INSTALL_DIR" 2>/dev/null || true
fi
echo ""
echo "Uninstall complete."
echo "If you previously added $INSTALL_DIR to your PATH, you can remove that entry from your shell profile manually."