#!/bin/bash # ─< ANSI color codes >─────────────────────────────────────────────────────────────────── RED='\033[0;31m' BLUE='\033[0;34m' CYAN='\033[0;36m' GREEN='\033[0;32m' YELLOW='\033[0;33m' LIGHT_GREEN='\033[0;92m' BOLD='\033[1m' NC='\033[0m' # No Color echo_error() { printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2 } echo_info() { printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1" } echo_warning() { printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1" } echo_note() { printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1" } # ─< Check if the given command exists silently >───────────────────────────────────────── command_exists() { command -v "$@" >/dev/null 2>&1 } # ─< Check if the user is root and set sudo variable if necessary >─────────────────────── check_root() { if [ "$(id -u)" -ne 0 ]; then if command_exists sudo; then echo_info "User is not root. Using sudo for privileged operations." _sudo="sudo" else echo_error "No sudo found and you're not root! Can't install packages." return 1 fi else echo_info "Root access confirmed." _sudo="" fi } # Function to print colored text print_color() { printf "%b%s%b\n" "$1" "$2" "$NC" } # Function to return to the main menu return_to_menu() { echo_info "Returning to the main menu in 3 seconds..." sleep 3 } gitDir="$HOME/git/dotfiles" dotRemote="https://git.k4li.de/dotfiles" instRemote="https://git.k4li.de/scripts/sh/raw/branch/main/installs" if [ ! -d "$gitDir" ]; then print_color "$RED" "=== git dir created - $gitDir ===" mkdir -p "$gitDir" fi d_="git curl" for dependency in $d_; do if ! command_exists "$dependency"; then print_color "$RED" "You're missing some dependencies!" print_color "$RED" "Install $dependency and start the script again" exit 1 fi done # Function to display the menu display_menu() { clear print_color "$BLUE" "=== Environment Setup Menu ===" for i in "${!options[@]}"; do if [[ $i -eq $selected ]]; then print_color "$GREEN" "> ${options[$i]}" else echo " ${options[$i]}" fi done } # Function to handle dotfiles setup nvimSetup() { print_color "$YELLOW" "Setting up neovim..." if [ ! -d "$HOME/.config/nvim" ]; then echo_note "Installing into .config directly" git clone --branch minimal --recurse-submodule --depth=1 "${dotRemote}/nvim.git" "$HOME/.config/nvim" else if [ -d "$gitDir/nvim" ]; then cd "$gitDir/nvim" || { echo_error "The given path - $gitDir/nvim - was not found!" return 1 } git pull --recurse-submodule else echo_note "Installing into $gitDir/nvim" git clone --branch minimal --recurse-submodule --depth=1 "${dotRemote}/nvim.git" "$gitDir/nvim" fi fi return_to_menu } # Function to handle CLI tool installation nvimMinimalSetup() { print_color "$YELLOW" "Setting up neovim minimal branch..." if [ ! -d "$HOME/.config/nvim" ]; then echo_note "Installing into .config directly" git clone --branch minimal --recurse-submodule --depth=1 "${dotRemote}/nvim.git" "$HOME/.config/nvim" else if [ -d "$gitDir/nvim-minimal" ]; then cd "$gitDir/nvim-minimal" || { echo_error "The given path - $gitDir/nvim-minimal - was not found!" return 1 } git pull --recurse-submodule else echo_note "Installing into $gitDir/nvim-minimal" git clone --branch minimal --recurse-submodule --depth=1 "${dotRemote}/nvim.git" "$gitDir/nvim-minimal" fi fi return_to_menu } installStuff() { echo_info "I want to install.." read -r gitPackage