From 3a3554bfe62fcd018beb31270302b727052989b4 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 9 May 2026 18:04:28 +0000 Subject: [PATCH] setup.sh aktualisiert --- setup.sh | 123 +++++++++++++++++++++++++++---------------------------- 1 file changed, 60 insertions(+), 63 deletions(-) diff --git a/setup.sh b/setup.sh index 47ccba6..c687223 100644 --- a/setup.sh +++ b/setup.sh @@ -1,82 +1,79 @@ #!/bin/sh -# --- 1. Deine individuellen Datei-URLs --- -URL_NVIM_INIT="http://DEIN_GITEA/init.lua" -URL_FASTFETCH="http://DEIN_GITEA/fastfetch.jsonc" +# --- 1. Konfiguration --- +GITEA_RAW="https://git.ungruhe.info/Tim/dotfiles/raw/branch/main" -echo "🔍 Scanne System (POSIX mode)..." +echo "🔍 Scanne System-Umgebung..." -# --- 2. System-Erkennung (sh-kompatibel) --- -if [ -f /etc/os-release ]; then +# --- 2. Erweiterte System-Erkennung (Inkl. Termux) --- +if [ -d "/data/data/com.termux/files/usr" ]; then + SPECIFIC_ID="termux" + BASE_ID="android" + BIN_PATH="/data/data/com.termux/files/usr/bin" +elif [ -f /etc/os-release ]; then . /etc/os-release - OS_ID=$ID + SPECIFIC_ID=$ID + BASE_ID=$ID_LIKE + BIN_PATH="/usr/bin" else - OS_ID="unknown" + SPECIFIC_ID="unknown" + BASE_ID="unknown" + BIN_PATH="/usr/bin" fi -# --- 3. Voraussetzungen installieren --- -# Wir prüfen erst, welcher Manager da ist -echo "📦 Installiere Pakete für: $OS_ID..." -if command -v sudo >/dev/null 2>&1; then S="sudo"; else S=""; fi +# --- 3. Pakete installieren --- +echo "📦 Installiere Voraussetzungen für $SPECIFIC_ID..." -if command -v apt-get >/dev/null 2>&1; then - $S apt-get update && $S apt-get install -y zsh curl git neovim fastfetch eza -elif command -v pacman >/dev/null 2>&1; then - $S pacman -Syu --needed --noconfirm zsh curl git neovim fastfetch eza shadow -elif command -v apk >/dev/null 2>&1; then - $S apk add zsh curl git neovim fastfetch eza shadow ncurses-terminfo-base -elif command -v dnf >/dev/null 2>&1; then - $S dnf install -y zsh curl git neovim fastfetch eza shadow-utils +# Sudo Logik (Termux braucht kein Sudo) +if command -v sudo >/dev/null 2>&1 && [ "$SPECIFIC_ID" != "termux" ]; then + S="sudo" +else + S="" fi -# --- 4. Verzeichnisse & Downloads --- +case "$SPECIFIC_ID" in + termux) + pkg update && pkg install -y zsh curl git neovim fastfetch eza ncurses-utils ;; + *arch*|*cachyos*) + $S pacman -Syu --needed --noconfirm zsh curl git neovim fastfetch eza shadow ;; + *debian*|*ubuntu*|*trixie*) + $S apt-get update && $S apt-get install -y zsh curl git neovim fastfetch eza ;; + *alpine*) + $S apk add zsh curl git neovim fastfetch eza shadow ncurses-terminfo-base ;; +esac + +# --- 4. Verzeichnisse erstellen (Termux-Safe) --- +# In Termux ist $HOME meist /data/data/com.termux/files/home mkdir -p "$HOME/.config/nvim" "$HOME/.config/fastfetch" -curl -fsSL "$URL_NVIM_INIT" -o "$HOME/.config/nvim/init.lua" -curl -fsSL "$URL_FASTFETCH" -o "$HOME/.config/fastfetch/fastfetch.jsonc" -# --- 5. Die dynamische .zshrc Erstellung --- -# Wir nutzen hier 'cat' ohne Bash-Variablen-Tricks -echo "📝 Generiere .zshrc..." +# --- 5. .zshrc mit Fallback laden --- +echo "📥 Lade ZSH-Konfiguration..." +SUCCESS=0 -cat < "$HOME/.zshrc" -# --- Automatisch generiert am $(date) --- -OS_ID="$OS_ID" +# Suchreihenfolge: spezifische ID -> Basis ID -> default +for TARGET in "$SPECIFIC_ID" "$BASE_ID" "default"; do + if [ -n "$TARGET" ] && [ "$SUCCESS" -eq 0 ]; then + if curl -fsSL "${GITEA_RAW}/.zshrc${TARGET}" -o "$HOME/.zshrc"; then + echo "✅ Erfolg mit .zshrc${TARGET}" + SUCCESS=1 + fi + fi +done -# Zinit Installation -ZINIT_HOME="\$HOME/.local/share/zinit/zinit.git" -if [ ! -d "\$ZINIT_HOME" ]; then - mkdir -p "\$(dirname "\$ZINIT_HOME")" - git clone https://github.com/zdharma-continuum/zinit.git "\$ZINIT_HOME" -fi -source "\$ZINIT_HOME/zinit.zsh" +# --- 6. Restliche Configs --- +curl -fsSL "${GITEA_RAW}/init.lua" -o "$HOME/.config/nvim/init.lua" +curl -fsSL "${GITEA_RAW}/fastfetch.jsonc" -o "$HOME/.config/fastfetch/fastfetch.jsonc" -zinit ice depth=1; zinit light romkatv/powerlevel10k -zinit light zsh-users/zsh-syntax-highlighting -zinit light zsh-users/zsh-autosuggestions - -# Fastfetch & Aliases -alias l='eza -lagh --icons --group-directories-first' -alias c='clear' -alias x='exit' -(( \$+commands[fastfetch] )) && fastfetch --config \$HOME/.config/fastfetch/fastfetch.jsonc - -EOF - -# --- 6. Update-Logik (System-spezifisch) --- -if [ "$OS_ID" = "debian" ] || [ "$OS_ID" = "ubuntu" ] || [ "$OS_ID" = "trixie" ]; then - echo "update_system() { $S apt-get update && $S apt-get upgrade -y; }" >> "$HOME/.zshrc" -elif [ "$OS_ID" = "arch" ] || [ "$OS_ID" = "cachyos" ]; then - echo "update_system() { $S pacman -Syu --noconfirm; }" >> "$HOME/.zshrc" -elif [ "$OS_ID" = "alpine" ]; then - echo "update_system() { $S apk update && $S apk upgrade; }" >> "$HOME/.zshrc" -fi -echo "alias u='update_system'" >> "$HOME/.zshrc" - -# --- 7. Finale --- -# Prüfen ob ZSH die Default Shell ist (optional) -if [ "$SHELL" != "$(command -v zsh)" ] && [ "$OS_ID" != "termux" ]; then - $S chsh -s "$(command -v zsh)" "$(whoami)" +# --- 7. Shell-Wechsel --- +# In Termux gibt es kein 'chsh' im klassischen Sinne oder es funktioniert anders +if [ "$SPECIFIC_ID" = "termux" ]; then + # Setzt ZSH als Login-Shell für Termux + chsh -s zsh >/dev/null 2>&1 +else + if [ "$SHELL" != "$(command -v zsh)" ]; then + $S chsh -s "$(command -v zsh)" "$(whoami)" + fi fi -echo "✅ Setup fertig! Starte ZSH..." +echo "🚀 Setup abgeschlossen! Starte ZSH..." exec zsh -l \ No newline at end of file