diff --git a/setup.sh b/setup.sh index 245dea9..2c184c3 100644 --- a/setup.sh +++ b/setup.sh @@ -1,9 +1,58 @@ -sudo apt update; sudo apt upgrade -sudo add-apt-repository ppa:zhangsongcui3371/fastfetch +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status. +set -e + +# --- 1. System Preparation --- +echo "▶️ Starting system preparation..." sudo apt update -sudo apt install fastfetch -sudo apt install btop zoxide bat -zoxide init bash >> ~/.bashrc -source ~/.bashrc -sudo apt install -y ca-certificates curl gnupg lsb-release -sudo mkdir -p /etc/apt/keyrings +echo "▶️ Upgrading system packages. This may take a while..." +sudo apt upgrade -y + +echo "▶️ Installing essential dependencies for Homebrew..." +# build-essential is recommended by Homebrew for compiling packages +sudo apt install -y build-essential procps curl file git ca-certificates gnupg lsb-release + +# --- 2. Homebrew Installation --- +# Check if Homebrew is already installed before proceeding +if command -v brew &>/dev/null; then + echo "✅ Homebrew is already installed. Skipping installation." +else + echo "▶️ Installing Homebrew..." + # Use the NONINTERACTIVE flag to prevent the script from pausing for user input. + NONINTERACTIVE=1 /bin/bash -c \ + "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + +# --- 3. Configure Homebrew Environment --- +# The Homebrew installer adds its configuration path to .profile. +# We need to source it to make the 'brew' command available in this script session. +# This setup works for standard Linux installations. +echo "▶️ Configuring shell environment for Homebrew..." +if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then + # Add Homebrew to PATH for the current script execution + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + + # Add Homebrew to your .bashrc for future sessions, if not already present + if ! grep -q 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' ~/.bashrc; then + echo '' >>~/.bashrc + echo '# Add Homebrew to PATH' >>~/.bashrc + echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >>~/.bashrc + echo "✅ Homebrew environment configured in ~/.bashrc for future sessions." + else + echo "✅ Homebrew environment already configured in ~/.bashrc." + fi +else + echo "❌ Could not find Homebrew installation. Exiting." + exit 1 +fi + +# --- 4. Install Packages via Homebrew --- +echo "▶️ Installing packages with Homebrew..." +brew install zoxide btop nvtop bat fastfetch + +# --- 5. Finalizing --- +echo "" +echo "🎉 All done! Your new tools have been installed." +echo "To start using them, please open a new terminal or run:" +echo "source ~/.bashrc" \ No newline at end of file