#!/bin/bash # Function to check if git is installed check_git_installed() { if ! command -v git > /dev/null; then echo "git is not installed. Attempting to install..." if command -v apt > /dev/null; then sudo apt update && sudo apt install -y git elif command -v dnf > /dev/null; then sudo dnf makecache && sudo dnf install -y git elif command -v yum > /dev/null; then sudo yum makecache && sudo yum install -y git else echo "Unsupported package manager. Please install git manually." exit 1 fi fi } # Function to install unzip and bun install_unzip_and_bun() { if command -v apt > /dev/null; then sudo apt update && sudo apt install -y unzip elif command -v dnf > /dev/null; then sudo dnf makecache && sudo dnf install -y unzip elif command -v yum > /dev/null; then sudo yum makecache && sudo yum install -y unzip else echo "Unsupported package manager. Please install unzip manually." exit 1 fi # Install bun curl -fsSL https://bun.sh/install | bash # Add bun to PATH in .bashrc and current session echo 'export BUN_INSTALL="$HOME/.bun"' >> ~/.bashrc echo 'export PATH="$BUN_INSTALL/bin:$PATH"' >> ~/.bashrc export BUN_INSTALL="$HOME/.bun" export PATH="$BUN_INSTALL/bin:$PATH" } # Function to install nvm and Node.js install_nvm_and_node() { # Install nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash # Load nvm export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # Install Node.js using nvm nvm install 20 } # Check for curl and bash if ! command -v curl > /dev/null || ! command -v bash > /dev/null; then echo "This script requires curl and bash. Please install them and try again." exit 1 fi # Check and install git if necessary check_git_installed # Execute installation functions install_unzip_and_bun install_nvm_and_node case "$SHELL" in */zsh) if [ -f ~/.zshrc ]; then . ~/.zshrc fi ;; */bash) if [ -f ~/.bashrc ]; then . ~/.bashrc fi ;; *) echo "Unsupported shell: $SHELL" ;; esac echo "Installation complete."