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
55 changes: 25 additions & 30 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ elif [ -f /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
DISTRO="${ID:-unknown}"
DISTRO_LIKE="${ID_LIKE:-unknown}" # Catches derivatives (e.g. ID_LIKE="debian")
DISTRO_LIKE="${ID_LIKE:-unknown}"
fi

echo -e "${BLUE}Detected OS: ${OS_TYPE} (${DISTRO})${NC}"

# Resolve distro family from ID or ID_LIKE
_resolve_distro_family() {
local id="$1"
local id_like="$2"
Expand All @@ -82,7 +81,7 @@ _resolve_distro_family() {
opensuse*|suse*)
echo "suse" ;;
*)
# Fall back to ID_LIKE for unrecognised derivatives
# ID_LIKE can be space-separated (e.g. "rhel fedora"); glob covers it
case "$id_like" in
*debian*|*ubuntu*) echo "debian" ;;
*arch*) echo "arch" ;;
Expand All @@ -94,49 +93,48 @@ _resolve_distro_family() {
esac
}

# Do not overwrite macOS family
if [[ "$OS_TYPE" != "macos" ]]; then
DISTRO_FAMILY="$(_resolve_distro_family "$DISTRO" "$DISTRO_LIKE")"
fi

# Verify sudo is available on Linux before attempting privileged installs
if [[ "$OS_TYPE" == "linux" ]] && ! command -v sudo &>/dev/null; then
echo -e "${RED}sudo is required but not found. Please install sudo or run as root.${NC}"
exit 1
fi
Comment on lines +100 to +104

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Contradictory error message regarding root execution.

The message suggests "run as root" as an alternative, but the script explicitly rejects root execution at lines 27-31 (unless CI_ENV=true). This could confuse users on minimal systems without sudo.

Proposed fix
 if [[ "$OS_TYPE" == "linux" ]] && ! command -v sudo &>/dev/null; then
-    echo -e "${RED}sudo is required but not found. Please install sudo or run as root.${NC}"
+    echo -e "${RED}sudo is required but not found. Please install sudo first.${NC}"
     exit 1
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@install.sh` around lines 100 - 104, The error message in the sudo
availability check (the conditional using OS_TYPE and command -v sudo)
contradicts the script's earlier refusal to run as root (unless CI_ENV=true);
change the echo to only recommend installing sudo or configuring CI_ENV=true for
CI runs (remove "or run as root"), or alternatively update the logic to allow
root by checking UID==0 and proceeding when appropriate; specifically modify the
sudo-check block that references OS_TYPE and CI_ENV so the message and behavior
are consistent with the root-rejection logic elsewhere.


install_pkg() {
local pkgs=("$@")
echo -e "${YELLOW}Installing: ${pkgs[*]}...${NC}"

case "$DISTRO_FAMILY" in
debian)
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update -qq -y > /dev/null || {
echo -e "${RED}Failed: apt-get update${NC}"
exit 1
sudo apt-get update -qq > /dev/null || { # -y is invalid for update
echo -e "${RED}Failed: apt-get update${NC}"; exit 1
}
sudo apt-get install -qq -y "${pkgs[@]}" > /dev/null || {
echo -e "${RED}Failed to install ${pkgs[*]} via apt-get${NC}"
exit 1
echo -e "${RED}Failed to install ${pkgs[*]} via apt-get${NC}"; exit 1
}
;;
arch)
sudo pacman -Sy --quiet --noconfirm --needed "${pkgs[@]}" > /dev/null || {
echo -e "${RED}Failed to install ${pkgs[*]} via pacman${NC}"
exit 1
sudo pacman -Sy -q --noconfirm --needed "${pkgs[@]}" > /dev/null || { # --quiet -> -q
echo -e "${RED}Failed to install ${pkgs[*]} via pacman${NC}"; exit 1
}
;;
fedora)
sudo dnf install -q -y "${pkgs[@]}" > /dev/null || {
echo -e "${RED}Failed to install ${pkgs[*]} via dnf${NC}"
exit 1
echo -e "${RED}Failed to install ${pkgs[*]} via dnf${NC}"; exit 1
}
;;
suse)
sudo zypper install -q -y "${pkgs[@]}" > /dev/null || {
echo -e "${RED}Failed to install ${pkgs[*]} via zypper${NC}"
exit 1
echo -e "${RED}Failed to install ${pkgs[*]} via zypper${NC}"; exit 1
}
;;
macos)
brew install -q "${pkgs[@]}" > /dev/null || {
echo -e "${RED}Failed to install ${pkgs[*]} via brew${NC}"
exit 1
echo -e "${RED}Failed to install ${pkgs[*]} via brew${NC}"; exit 1
}
;;
*)
Expand All @@ -151,17 +149,13 @@ install_pkg() {
# 1. PRE-REQUISITES (Homebrew for macOS)
# =============================================================================
if [[ "$OS_TYPE" == "macos" ]]; then
if ! command -v brew &> /dev/null; then
if ! command -v brew &>/dev/null; then
echo -e "${YELLOW}Homebrew not found. Installing Homebrew (this may take a while)...${NC}"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" > /dev/null || {
echo -e "${RED}Homebrew installation failed.${NC}"; exit 1
}
# Support both Apple Silicon (/opt/homebrew) and Intel (/usr/local) paths
if [ -f "/opt/homebrew/bin/brew" ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [ -f "/usr/local/bin/brew" ]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
# Let Homebrew itself report its prefix — handles Intel, Apple Silicon, and custom paths
eval "$(brew shellenv 2>/dev/null || true)"
fi
fi

Expand All @@ -170,14 +164,15 @@ fi
# =============================================================================
echo -e "${YELLOW}Installing base dependencies...${NC}"

COMMON_DEPS=(git curl wget unzip zsh gnupg)

if [[ "$OS_TYPE" == "macos" ]]; then
install_pkg "${COMMON_DEPS[@]}"
# zsh ships with macOS 10.15+; omit to avoid a no-op warning from Homebrew
COMMON_DEPS=(git curl wget unzip gnupg)
else
install_pkg "${COMMON_DEPS[@]}"
COMMON_DEPS=(git curl wget unzip zsh gnupg)
fi

install_pkg "${COMMON_DEPS[@]}"

# =============================================================================
# 2.1 CLIPBOARD UTILITY
# =============================================================================
Expand Down Expand Up @@ -244,7 +239,7 @@ else
sudo chmod 644 /etc/apt/keyrings/gierens.gpg \
/etc/apt/sources.list.d/gierens.list

sudo apt-get update -qq -y > /dev/null && sudo apt-get install -qq -y eza > /dev/null
sudo apt-get update -qq > /dev/null && sudo apt-get install -qq -y eza > /dev/null
;;

fedora)
Expand Down