setup.sh aktualisiert
This commit is contained in:
@@ -1,82 +1,79 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# --- 1. Deine individuellen Datei-URLs ---
|
# --- 1. Konfiguration ---
|
||||||
URL_NVIM_INIT="http://DEIN_GITEA/init.lua"
|
GITEA_RAW="https://git.ungruhe.info/Tim/dotfiles/raw/branch/main"
|
||||||
URL_FASTFETCH="http://DEIN_GITEA/fastfetch.jsonc"
|
|
||||||
|
|
||||||
echo "🔍 Scanne System (POSIX mode)..."
|
echo "🔍 Scanne System-Umgebung..."
|
||||||
|
|
||||||
# --- 2. System-Erkennung (sh-kompatibel) ---
|
# --- 2. Erweiterte System-Erkennung (Inkl. Termux) ---
|
||||||
if [ -f /etc/os-release ]; then
|
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
|
. /etc/os-release
|
||||||
OS_ID=$ID
|
SPECIFIC_ID=$ID
|
||||||
|
BASE_ID=$ID_LIKE
|
||||||
|
BIN_PATH="/usr/bin"
|
||||||
else
|
else
|
||||||
OS_ID="unknown"
|
SPECIFIC_ID="unknown"
|
||||||
|
BASE_ID="unknown"
|
||||||
|
BIN_PATH="/usr/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- 3. Voraussetzungen installieren ---
|
# --- 3. Pakete installieren ---
|
||||||
# Wir prüfen erst, welcher Manager da ist
|
echo "📦 Installiere Voraussetzungen für $SPECIFIC_ID..."
|
||||||
echo "📦 Installiere Pakete für: $OS_ID..."
|
|
||||||
if command -v sudo >/dev/null 2>&1; then S="sudo"; else S=""; fi
|
|
||||||
|
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
# Sudo Logik (Termux braucht kein Sudo)
|
||||||
$S apt-get update && $S apt-get install -y zsh curl git neovim fastfetch eza
|
if command -v sudo >/dev/null 2>&1 && [ "$SPECIFIC_ID" != "termux" ]; then
|
||||||
elif command -v pacman >/dev/null 2>&1; then
|
S="sudo"
|
||||||
$S pacman -Syu --needed --noconfirm zsh curl git neovim fastfetch eza shadow
|
else
|
||||||
elif command -v apk >/dev/null 2>&1; then
|
S=""
|
||||||
$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
|
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"
|
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 ---
|
# --- 5. .zshrc mit Fallback laden ---
|
||||||
# Wir nutzen hier 'cat' ohne Bash-Variablen-Tricks
|
echo "📥 Lade ZSH-Konfiguration..."
|
||||||
echo "📝 Generiere .zshrc..."
|
SUCCESS=0
|
||||||
|
|
||||||
cat <<EOF > "$HOME/.zshrc"
|
# Suchreihenfolge: spezifische ID -> Basis ID -> default
|
||||||
# --- Automatisch generiert am $(date) ---
|
for TARGET in "$SPECIFIC_ID" "$BASE_ID" "default"; do
|
||||||
OS_ID="$OS_ID"
|
if [ -n "$TARGET" ] && [ "$SUCCESS" -eq 0 ]; then
|
||||||
|
if curl -fsSL "${GITEA_RAW}/.zshrc${TARGET}" -o "$HOME/.zshrc"; then
|
||||||
# Zinit Installation
|
echo "✅ Erfolg mit .zshrc${TARGET}"
|
||||||
ZINIT_HOME="\$HOME/.local/share/zinit/zinit.git"
|
SUCCESS=1
|
||||||
if [ ! -d "\$ZINIT_HOME" ]; then
|
|
||||||
mkdir -p "\$(dirname "\$ZINIT_HOME")"
|
|
||||||
git clone https://github.com/zdharma-continuum/zinit.git "\$ZINIT_HOME"
|
|
||||||
fi
|
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 & 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
|
fi
|
||||||
echo "alias u='update_system'" >> "$HOME/.zshrc"
|
done
|
||||||
|
|
||||||
# --- 7. Finale ---
|
# --- 6. Restliche Configs ---
|
||||||
# Prüfen ob ZSH die Default Shell ist (optional)
|
curl -fsSL "${GITEA_RAW}/init.lua" -o "$HOME/.config/nvim/init.lua"
|
||||||
if [ "$SHELL" != "$(command -v zsh)" ] && [ "$OS_ID" != "termux" ]; then
|
curl -fsSL "${GITEA_RAW}/fastfetch.jsonc" -o "$HOME/.config/fastfetch/fastfetch.jsonc"
|
||||||
|
|
||||||
|
# --- 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)"
|
$S chsh -s "$(command -v zsh)" "$(whoami)"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "✅ Setup fertig! Starte ZSH..."
|
echo "🚀 Setup abgeschlossen! Starte ZSH..."
|
||||||
exec zsh -l
|
exec zsh -l
|
||||||
Reference in New Issue
Block a user