setup.sh aktualisiert

This commit is contained in:
Tim
2026-05-09 16:56:48 +00:00
parent 822f0f3c2c
commit b937fcf274
+48 -69
View File
@@ -1,103 +1,82 @@
#!/bin/bash
#!/bin/sh
# --- 1. Deine individuellen Datei-URLs ---
URL_NVIM_INIT="https://git.ungruhe.info/Tim/dotfiles/raw/branch/main/.config/nvim/init.lua"
URL_FASTFETCH="https://git.ungruhe.info/Tim/dotfiles/raw/branch/main/.config/fastfetch/fastfetch.jsonc"
URL_NVIM_INIT="http://DEIN_GITEA/init.lua"
URL_FASTFETCH="http://DEIN_GITEA/fastfetch.jsonc"
echo "🔍 Scanne System für maßgeschneidertes Setup..."
echo "🔍 Scanne System (POSIX mode)..."
# --- 2. System-Erkennung ---
# --- 2. System-Erkennung (sh-kompatibel) ---
if [ -f /etc/os-release ]; then
. /etc/os-release
OS_ID=$ID
OS_LIKE=$ID_LIKE
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS_ID="macos"
else
OS_ID="unknown"
fi
# --- 3. Intelligente Paket-Installation ---
# --- 3. Voraussetzungen installieren ---
# Wir prüfen erst, welcher Manager da ist
echo "📦 Installiere Pakete für: $OS_ID..."
SUDO=""
command -v sudo >/dev/null && SUDO="sudo"
if command -v sudo >/dev/null 2>&1; then S="sudo"; else S=""; fi
case "$OS_ID" in
arch|cachyos)
$SUDO pacman -Syu --needed --noconfirm zsh curl git neovim fastfetch eza shadow ;;
debian|ubuntu|trixie|kali)
$SUDO apt update && $SUDO apt install -y zsh curl git neovim fastfetch eza ;;
alpine)
$SUDO apk add zsh curl git neovim fastfetch eza shadow ncurses-terminfo-base ;;
*)
echo "⚠️ System $OS_ID nicht explizit unterstützt, versuche Standard-ZSH..."
$SUDO apt install -y zsh curl || echo "Installation fehlgeschlagen." ;;
esac
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
fi
# --- 4. Verzeichnisse & Config-Downloads ---
mkdir -p ~/.config/nvim ~/.config/fastfetch
curl -fsSL "$URL_NVIM_INIT" -o ~/.config/nvim/init.lua
curl -fsSL "$URL_FASTFETCH" -o ~/.config/fastfetch/fastfetch.jsonc
# --- 4. Verzeichnisse & Downloads ---
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 ---
echo "📝 Generiere optimierte .zshrc für $OS_ID..."
# Wir nutzen hier 'cat' ohne Bash-Variablen-Tricks
echo "📝 Generiere .zshrc..."
cat <<EOF > ~/.zshrc
cat <<EOF > "$HOME/.zshrc"
# --- Automatisch generiert am $(date) ---
OS_ID="$OS_ID"
OS_LIKE="$OS_LIKE"
# Basis-Plugins & Theme (Zinit)
ZINIT_HOME="\${XDG_DATA_HOME:-\${HOME}/.local/share}/zinit/zinit.git"
[ ! -d "\$ZINIT_HOME" ] && mkdir -p "\$(dirname \$ZINIT_HOME)" && git clone https://github.com/zdharma-continuum/zinit.git "\$ZINIT_HOME"
source "\${ZINIT_HOME}/zinit.zsh"
# 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"
zinit ice depth=1; zinit light romkatv/powerlevel10k
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-autosuggestions
# Fastfetch Start
(( \$+commands[fastfetch] )) && fastfetch --config ~/.config/fastfetch/fastfetch.jsonc
# --- System-spezifische Aliases ---
# 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. Effiziente Update-Logik einfügen ---
# Hier wird nur der Code eingefügt, den das aktuelle System wirklich braucht!
case "$OS_ID" in
arch|cachyos)
cat <<'EOF' >> ~/.zshrc
update_system() {
echo "--- Arch Update ---"
if (( $+commands[yay] )); then yay -Syu --noconfirm; else sudo pacman -Syu --noconfirm; fi
sudo pacman -Rns $(pacman -Qdtq) --noconfirm 2>/dev/null
}
EOF
;;
debian|ubuntu|trixie|kali)
cat <<'EOF' >> ~/.zshrc
update_system() {
echo "--- Debian/APT Update ---"
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
}
EOF
;;
alpine)
cat <<'EOF' >> ~/.zshrc
update_system() {
echo "--- Alpine Update ---"
sudo apk update && sudo apk upgrade
}
EOF
;;
esac
# --- 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"
echo "alias u='update_system'" >> ~/.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)"
fi
# --- 7. Finale & Start ---
echo "✅ Setup fertig. Wechsel zu ZSH..."
echo "✅ Setup fertig! Starte ZSH..."
exec zsh -l