diff --git a/.zshenv b/.zshenv new file mode 100644 index 0000000..a717e5a --- /dev/null +++ b/.zshenv @@ -0,0 +1 @@ +# ENV File \ No newline at end of file diff --git a/.zshrc b/.zshrc index 808d532..52c08bb 100644 --- a/.zshrc +++ b/.zshrc @@ -1,26 +1,26 @@ # .zshrc -# Path to your Oh My Zsh installation. +# Zsh Configuration export ZSH="$HOME/.oh-my-zsh" PROMPT="%B%~%b :: " RPROMPT="%n@%m" -# Plugins -plugins=(git zsh-syntax-highlighting zsh-autosuggestions) +# Programming Languages Root +export PROG_DIR="$HOME/.programming" -source $ZSH/oh-my-zsh.sh +# 1. Go and GVM (Black Box) +export GVM_ROOT="$PROG_DIR/go" +# Only source if the custom GVM exists +[[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm" -# Golang and GVM -[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm" - -# Node and NVM (Lazy Load) -export NVM_DIR="$HOME/.nvm" +# 2. Node and NVM (Lazy Load) +export NVM_DIR="$PROG_DIR/node" nvm_load() { echo "💤 Waking up NVM..." unset -f nvm node npm npx - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" "$@" } @@ -29,8 +29,22 @@ node() { nvm_load "node" "$@"; } npm() { nvm_load "npm" "$@"; } npx() { nvm_load "npx" "$@"; } -# Rust and Cargo -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" +# 3. Rust and Cargo +export RUSTUP_HOME="$PROG_DIR/rust/multirust" +export CARGO_HOME="$PROG_DIR/rust/cargo" + +# 4. Python (Pyenv + Miniconda) +export PYENV_ROOT="$PROG_DIR/python/pyenv" +export PATH="$PYENV_ROOT/bin:$PATH" + +if command -v pyenv 1>/dev/null 2>&1; then + eval "$(pyenv init -)" +fi + +if command -v conda >/dev/null 2>&1; then + CONDA_BASE=$(conda info --base) + [ -f "$CONDA_BASE/etc/profile.d/conda.sh" ] && source "$CONDA_BASE/etc/profile.d/conda.sh" +fi # Zoxide eval "$(zoxide init --cmd cd zsh)" @@ -39,19 +53,11 @@ eval "$(zoxide init --cmd cd zsh)" [ -f ~/.zsh_aliases ] && source ~/.zsh_aliases [ -f ~/.zsh_secrets ] && source ~/.zsh_secrets -# Conda (Dynamic Path) -# __conda_setup="$('$HOME/Programming/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)" -# if [ $? -eq 0 ]; then -# eval "$__conda_setup" -# else -# if [ -f "$HOME/Programming/miniconda3/etc/profile.d/conda.sh" ]; then -# . "$HOME/Programming/miniconda3/etc/profile.d/conda.sh" -# else -# export PATH="$HOME/Programming/miniconda3/bin:$PATH" -# fi -# fi -# unset __conda_setup +# Plugins +plugins=(git zsh-syntax-highlighting zsh-autosuggestions sudo rclone rust nvm golang conda pyenv) + +source $ZSH/oh-my-zsh.sh # Add to PATH -export PATH="$HOME/.local/bin:$PATH" -export PATH="/usr/local/go/bin:$PATH" +export PATH="$HOME/.local/bin:$CARGO_HOME/bin:$PATH" +export PATH="$GOPATH/bin:$PATH" \ No newline at end of file diff --git a/Makefile b/Makefile index 024cdc2..fffbb92 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Makefile for Dotfiles +# Makefile # Default target all: stow @@ -14,7 +14,7 @@ setup: # Just stow the dotfiles stow: - stow . --target=$$HOME --ignore=".git" --ignore=".gitignore" --ignore="README.md" --ignore=".zsh_secrets" --ignore=".zsh_secrets.example" --ignore="LICENSE" --ignore="Makefile" + stow . --target=$$HOME --ignore=".git" --ignore=".gitignore" --ignore="README.md" --ignore=".zsh_secrets" --ignore=".zsh_secrets.example" --ignore="LICENSE" --ignore="Makefile" --ignore="bin" --ignore="scripts" @echo "Dotfiles linked." # Clean old files and links diff --git a/scripts/base.sh b/scripts/base.sh index 995dca6..9eef1aa 100755 --- a/scripts/base.sh +++ b/scripts/base.sh @@ -1,7 +1,9 @@ #!/bin/bash + +# Path: scripts/base.sh + set -e -# Colors BLUE='\033[1;34m' YELLOW='\033[1;33m' GREEN='\033[1;32m' @@ -27,14 +29,12 @@ if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "aarch64" ]; then fi # 2. Package Installation (OS Dependencies) -# Note: Removed 'go', 'npm', 'cargo' - these are handled by specific scripts PACKAGES=( curl wget git sudo zsh tmux unzip tar gzip - build-essential openssl python bison mercurial + openssl python bison mercurial ripgrep fd bat fzf jq btop httpie gnupg zoxide stow bind nmap socat tcpdump net-tools strace gdb hexyl rclone - # 'eza' is REMOVED from here for Ubuntu logic below ) if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then @@ -42,10 +42,10 @@ if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then sudo pacman -Sy --noconfirm --needed "${PACKAGES[@]}" base-devel elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then sudo DEBIAN_FRONTEND=noninteractive apt-get update - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "${PACKAGES[@]}" bsdmainutils pkg-config cmake + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "${PACKAGES[@]}" bsdmainutils pkg-config cmake build-essential fi -# Moving Pre-Built bin to /usr/local/bin +# Moving Pre-Built bin to .local/bin mkdir -p "$HOME/.local/bin" cp -f "$REPO_ROOT/bin/"* "$HOME/.local/bin/" chmod +x "$HOME/.local/bin/"* diff --git a/scripts/go.sh b/scripts/go.sh index 4d56a79..959f2b4 100644 --- a/scripts/go.sh +++ b/scripts/go.sh @@ -1,46 +1,78 @@ #!/bin/bash + +# Path: scripts/go.sh + set -e + BLUE='\033[1;34m' YELLOW='\033[1;33m' GREEN='\033[1;32m' RED='\033[1;31m' NC='\033[0m' -echo -e "${BLUE} LOG:${YELLOW} Setting up Go (GVM)...${NC}" +# 1. Define Custom GVM Root +export GVM_ROOT="$HOME/.programming/go" +BOOTSTRAP_GO="$GVM_ROOT/bootstrap" -# 1. Install GVM dependencies -unalias cd 2>/dev/null || true +echo -e "${BLUE} LOG:${YELLOW} Setting up Go and GVM in ${GVM_ROOT}...${NC}" -# 2. Install GVM if missing -if [ ! -d "$HOME/.gvm" ]; then - bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) +# 2. Install GVM (Manual Method) +# Check for 'scripts' dir instead of '.git', because we are going to delete .git +if [ ! -d "$GVM_ROOT/scripts" ]; then + echo -e "${BLUE} LOG:${YELLOW} Cloning GVM...${NC}" + git clone https://github.com/moovweb/gvm.git "$GVM_ROOT" + + # CRITICAL FIX: Remove git metadata so GVM treats this as a valid installation + rm -rf "$GVM_ROOT/.git" + + # Generate the GVM executable script from default + echo -e "${BLUE} LOG:${YELLOW} Configuring GVM scripts...${NC}" + cp "$GVM_ROOT/scripts/gvm-default" "$GVM_ROOT/scripts/gvm" + sed -i "s|^GVM_ROOT=.*|GVM_ROOT=\"$GVM_ROOT\"|" "$GVM_ROOT/scripts/gvm" + + echo -e "${GREEN} SUCCESS:${NC} GVM cloned and configured." +else + echo -e "${GREEN} SKIP:${NC} GVM already installed." fi -# 3. Load GVM -[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm" - -# 4. Install Go -# Use a known stable version that exists. 1.24.11 is speculative. 1.24.0 is real. -TARGET_GO="go1.24.0" - -if command -v gvm &> /dev/null; then - if [[ $(gvm list) != *"$TARGET_GO"* ]]; then - echo -e "${BLUE} LOG:${YELLOW} Installing $TARGET_GO...${NC}" - - # Try Binary install first (Fastest/Safest) - gvm install "$TARGET_GO" -B || { - echo -e "${RED} LOG: Binary failed. Bootstrapping via go1.22.9...${NC}" - gvm install go1.22.9 -B - gvm use go1.22.9 - gvm install "$TARGET_GO" - } - - gvm use "$TARGET_GO" --default - echo -e "${GREEN} LOG: Go setup complete.$(go version)${NC}" - else - echo -e "${GREEN} LOG: $TARGET_GO already installed.${NC}" - fi +# 3. Install Universal Bootstrap Go +if [ ! -d "$BOOTSTRAP_GO" ]; then + echo -e "${BLUE} LOG:${YELLOW} Downloading Bootstrap Go...${NC}" + mkdir -p "$BOOTSTRAP_GO" + + wget -q https://go.dev/dl/go1.20.5.linux-amd64.tar.gz -O /tmp/go-bootstrap.tar.gz + tar -C "$BOOTSTRAP_GO" -xzf /tmp/go-bootstrap.tar.gz --strip-components=1 + rm /tmp/go-bootstrap.tar.gz + + echo -e "${GREEN} SUCCESS:${NC} Bootstrap Go installed." else - echo -e "${RED} ERROR: GVM failed to load.${NC}" + echo -e "${GREEN} SKIP:${NC} Bootstrap Go already exists." +fi + +# 4. Configure Environment for Installation +export PATH="$BOOTSTRAP_GO/bin:$PATH" +export GOROOT_BOOTSTRAP="$BOOTSTRAP_GO" + +# Source GVM +set +e +source "$GVM_ROOT/scripts/gvm" +set -e + +# Verify GVM loaded correctly +if ! command -v gvm &> /dev/null; then + echo -e "${RED} ERROR:${NC} GVM failed to load." exit 1 -fi \ No newline at end of file +fi + +# 5. Install Target Version +TARGET_VER="go1.24.11" + +if ! gvm list | grep -q "$TARGET_VER"; then + echo -e "${BLUE} LOG:${YELLOW} Installing ${TARGET_VER}...${NC}" + gvm install "$TARGET_VER" --prefer-binary +fi + +gvm use "$TARGET_VER" --default + +echo -e "${GREEN} SUCCESS:${NC} Go setup completed." + diff --git a/scripts/node.sh b/scripts/node.sh index 2f44962..7b29f47 100644 --- a/scripts/node.sh +++ b/scripts/node.sh @@ -1,33 +1,44 @@ #!/bin/bash -set -e # Exit on error +set -e +# Path: scripts/node.sh + BLUE='\033[1;34m' YELLOW='\033[1;33m' GREEN='\033[1;32m' NC='\033[0m' +# 1. Define Custom Path +export NVM_DIR="$HOME/.programming/node" + echo -e "${BLUE} LOG:${YELLOW} Setting up Node.js (NVM)...${NC}" -export NVM_DIR="$HOME/.nvm" - -# 1. Install NVM +# 2. Install NVM (if missing) if [ ! -d "$NVM_DIR" ]; then - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash + mkdir -p "$NVM_DIR" + echo -e "${BLUE} LOG:${YELLOW} Installing NVM to custom path...${NC}" + + # PROFILE=/dev/null prevents the installer from editing your .zshrc/.bashrc + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | PROFILE=/dev/null bash fi -# 2. Load NVM +# 3. Source NVM (Load it into current shell) [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -# 3. Install Node +# 4. Install Node if command -v nvm &> /dev/null; then echo -e "${BLUE} LOG:${YELLOW} Installing LTS...${NC}" nvm install --lts nvm use --lts echo -e "${BLUE} LOG:${YELLOW} Installing Global Tools...${NC}" - # set +e is safer for npm global installs which can be noisy + + # Disable strict error checking for npm global installs (they are noisy) set +e - npm install -g pnpm yarn + npm install -g pnpm yarn || true set -e - echo -e "${GREEN} LOG: Node setup complete.$(node -v)${NC}" + echo -e "${GREEN} LOG: Node setup complete. $(node -v)${NC}" +else + echo -e "${RED} ERROR: NVM failed to load from $NVM_DIR${NC}" + exit 1 fi \ No newline at end of file diff --git a/scripts/provision.sh b/scripts/provision.sh index 83df489..a27db71 100755 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -1,4 +1,7 @@ #!/bin/bash + +# Path: scripts/provision.sh + set -e # Colors @@ -44,7 +47,7 @@ if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then SUDO_GROUP="wheel" elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then apt-get update - apt-get install -y git make curl sudo + apt-get install -y git make curl sudo zsh SUDO_GROUP="sudo" else echo -e "${RED}Unsupported OS: $OS${NC}" diff --git a/scripts/python.sh b/scripts/python.sh index 0158da4..1b78e2e 100644 --- a/scripts/python.sh +++ b/scripts/python.sh @@ -1,15 +1,69 @@ #!/bin/bash +# Path: scripts/python.sh set -e -# Bold Colors -YELLOW='\033[1;33m' BLUE='\033[1;34m' -RED='\033[1;31m' +YELLOW='\033[1;33m' GREEN='\033[1;32m' +RED='\033[1;31m' NC='\033[0m' -# Python Setup -echo -e "${BLUE} LOG:${YELLOW} Setting up Python environment...${NC}" +# OS Detection +if [ -f /etc/os-release ]; then + . /etc/os-release + OS=$ID +fi -# MiniConda Installation \ No newline at end of file +# 1. Install Build Dependencies +if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then + echo -e "${BLUE} LOG:${YELLOW} Installing Arch build dependencies...${NC}" + sudo pacman -S --noconfirm --needed base-devel openssl zlib xz tk libffi bzip2 git +elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then + echo -e "${BLUE} LOG:${YELLOW} Installing Debian build dependencies...${NC}" + sudo DEBIAN_FRONTEND=noninteractive apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y make build-essential libssl-dev zlib1g-dev \ + libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ + libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev git +fi + +# 2. Define the Black Box Location +export PYENV_ROOT="$HOME/.programming/python/pyenv" +export PATH="$PYENV_ROOT/bin:$PATH" + +echo -e "${BLUE} LOG:${YELLOW} Setting up Pyenv in ${PYENV_ROOT}...${NC}" + +# 3. Install Pyenv +if [ ! -d "$PYENV_ROOT" ]; then + echo -e "${BLUE} LOG:${YELLOW} Cloning Pyenv...${NC}" + git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT" + + echo -e "${BLUE} LOG:${YELLOW} Compiling Pyenv dynamic bash extension...${NC}" + cd "$PYENV_ROOT" && src/configure && make -C src + + echo -e "${GREEN} SUCCESS:${NC} Pyenv installed." +else + echo -e "${GREEN} SKIP:${NC} Pyenv already installed." +fi + +# Initialize Pyenv for this script session +eval "$(pyenv init -)" + +# 4. Install Miniforge (The Community Standard) +TARGET_VER="miniforge3-latest" + +if ! pyenv versions | grep -q "$TARGET_VER"; then + echo -e "${BLUE} LOG:${YELLOW} Installing ${TARGET_VER}...${NC}" + echo -e "${YELLOW} NOTE: This avoids Anaconda licensing issues and uses conda-forge default.${NC}" + + pyenv install "$TARGET_VER" + + echo -e "${GREEN} SUCCESS:${NC} Miniforge installed." +else + echo -e "${GREEN} SKIP:${NC} Miniforge already installed." +fi + +# 5. Set Global Default +pyenv global "$TARGET_VER" + +echo -e "${GREEN} SUCCESS:${NC} Python setup completed. Default is now Miniforge (Conda)." \ No newline at end of file diff --git a/scripts/rust.sh b/scripts/rust.sh index e6f4a5a..fa0a22f 100644 --- a/scripts/rust.sh +++ b/scripts/rust.sh @@ -1,23 +1,38 @@ #!/bin/bash set -e +# Path: scripts/rust.sh + BLUE='\033[1;34m' YELLOW='\033[1;33m' GREEN='\033[1;32m' NC='\033[0m' +# 1. Define Custom Paths +export RUSTUP_HOME="$HOME/.programming/rust/multirust" +export CARGO_HOME="$HOME/.programming/rust/cargo" + echo -e "${BLUE} LOG:${YELLOW} Setting up Rust (Rustup)...${NC}" -# 1. Install Rustup -if ! command -v rustup &> /dev/null; then - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +# 2. Install Rustup (if missing) +if [ ! -f "$CARGO_HOME/bin/rustup" ]; then + echo -e "${BLUE} LOG:${YELLOW} Installing Rustup to custom path...${NC}" + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path +else + echo -e "${GREEN} LOG: Rustup already installed in custom path.${NC}" fi -# 2. Source Environment -[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" +# 3. Source Environment +if [ -f "$CARGO_HOME/env" ]; then + source "$CARGO_HOME/env" +fi -# 3. Update to Stable +# 4. Verify and Update if command -v cargo &> /dev/null; then + echo -e "${BLUE} LOG:${YELLOW} Updating toolchain...${NC}" rustup default stable rustup update echo -e "${GREEN} LOG: Rust setup complete.$(cargo --version)${NC}" +else + echo -e "${RED} ERROR: Cargo not found in PATH. Check CARGO_HOME.${NC}" + exit 1 fi \ No newline at end of file