setupscript/setup.sh
2025-06-10 15:21:46 +05:30

67 lines
No EOL
2.4 KiB
Bash

#!/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
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 gcc eza
# --- 5. Zoxide Init ---
zoxide init bash >> ~/.bashrc
source ~/.bashrc
# --- 6. Atuin --
curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh
source $HOME/.atuin/bin/env
# --- 7. Finalizing ---
source ~/.bashrc
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"