Skip to content

Instantly share code, notes, and snippets.

@ExilProductions
Last active November 29, 2025 14:26
Show Gist options
  • Select an option

  • Save ExilProductions/b8bb60eb290bf94a6c4e8dbf026a9adf to your computer and use it in GitHub Desktop.

Select an option

Save ExilProductions/b8bb60eb290bf94a6c4e8dbf026a9adf to your computer and use it in GitHub Desktop.
Linux VCPKG Quick install Script
#!/usr/bin/env bash
set -e
VCPKG_DIR="/opt/vcpkg"
BASHRC_FILE="$HOME/.bashrc"
ZSHRC_FILE="$HOME/.zshrc"
TAG="# >>> vcpkg PATH <<<"
uninstall() {
[ -d "$VCPKG_DIR" ] && sudo rm -rf "$VCPKG_DIR"
grep -q "$TAG" "$BASHRC_FILE" && sed -i "/$TAG/,/$TAG/d" "$BASHRC_FILE"
[ -f "$ZSHRC_FILE" ] && grep -q "$TAG" "$ZSHRC_FILE" && sed -i "/$TAG/,/$TAG/d" "$ZSHRC_FILE"
echo "vcpkg uninstalled"
exit 0
}
[[ "$1" == "--uninstall" ]] && uninstall
if command -v apt-get >/dev/null 2>&1; then PKG="apt"; elif command -v dnf >/dev/null 2>&1; then PKG="dnf"; elif command -v yum >/dev/null 2>&1; then PKG="yum"; elif command -v pacman >/dev/null 2>&1; then PKG="pacman"; elif command -v zypper >/dev/null 2>&1; then PKG="zypper"; else echo "Unsupported package manager"; exit 1; fi
case $PKG in
apt) sudo apt-get update && sudo apt-get install -y git build-essential curl unzip zip tar cmake ninja-build ;;
dnf) sudo dnf install -y git gcc gcc-c++ make curl unzip zip tar cmake ninja-build ;;
yum) sudo yum install -y git gcc gcc-c++ make curl unzip zip tar cmake ninja-build ;;
pacman) sudo pacman -Sy --needed --noconfirm git base-devel curl unzip zip tar cmake ninja ;;
zypper) sudo zypper install -y git gcc gcc-c++ make curl unzip zip tar cmake ninja ;;
esac
[ -d "$VCPKG_DIR" ] && sudo rm -rf "$VCPKG_DIR"
sudo git clone https://github.com/microsoft/vcpkg.git "$VCPKG_DIR"
sudo "$VCPKG_DIR/bootstrap-vcpkg.sh"
add_path() {
local RC="$1"
[ -f "$RC" ] && sed -i "/$TAG/,/$TAG/d" "$RC" && cat >> "$RC" <<EOF
$TAG
export VCPKG_ROOT="$VCPKG_DIR"
export PATH="\$PATH:\$VCPKG_ROOT"
$TAG
EOF
}
add_path "$BASHRC_FILE"
add_path "$ZSHRC_FILE"
echo "vcpkg installed. Reload shell: source ~/.bashrc or source ~/.zshrc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment