From 704f6023337dd19f4c8fdac910673bb9398c5295 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Tue, 28 Jul 2026 08:01:28 +0200 Subject: bootstrap: zsh.sh hinzugefuegt (Plugins, pwgen, mc, chsh) --- bootstrap/zsh.sh | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ readme.md | 6 +++ 2 files changed, 134 insertions(+) create mode 100755 bootstrap/zsh.sh diff --git a/bootstrap/zsh.sh b/bootstrap/zsh.sh new file mode 100755 index 0000000..b1780be --- /dev/null +++ b/bootstrap/zsh.sh @@ -0,0 +1,128 @@ +#!/bin/sh + +set -eu + +OS="$(uname -s)" + +die() { + printf 'Fehler: %s\n' "$*" >&2 + exit 1 +} + +have() { + command -v "$1" >/dev/null 2>&1 +} + +check_prerequisites() { + case "$OS" in + Darwin) + if ! have brew; then + die "Homebrew ist nicht installiert." + fi + ;; + FreeBSD) + if ! have doas; then + die "doas ist nicht installiert." + fi + ;; + *) + die "Nicht unterstütztes Betriebssystem: $OS" + ;; + esac +} + +setup_homebrew_env() { + case "$OS" in + Darwin) + export HOMEBREW_NO_AUTO_UPDATE=1 + export HOMEBREW_NO_INSTALL_CLEANUP=1 + ;; + esac +} + +install_pkg() { + binary="$1" + package="$2" + + if have "$binary"; then + printf "✓ %-32s vorhanden\n" "$binary" + return + fi + + printf "→ Installiere %s\n" "$package" + + case "$OS" in + Darwin) + brew install "$package" + ;; + FreeBSD) + doas pkg install -y "$package" + ;; + esac +} + +install_plugin() { + # zsh-syntax-highlighting/zsh-autosuggestions haben kein eigenes Binary, + # deshalb Pruefung anhand des von zsh/zshrc gesourceten Pfads. + file="$1" + package="$2" + + if [ -e "$file" ]; then + printf "✓ %-32s vorhanden\n" "$package" + return + fi + + printf "→ Installiere %s\n" "$package" + + case "$OS" in + Darwin) + brew install "$package" + ;; + FreeBSD) + doas pkg install -y "$package" + ;; + esac +} + +install_plugins() { + case "$OS" in + Darwin) + install_plugin "/opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" zsh-syntax-highlighting + install_plugin "/opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh" zsh-autosuggestions + ;; + FreeBSD) + install_plugin "/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" zsh-syntax-highlighting + install_plugin "/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh" zsh-autosuggestions + ;; + esac +} + +install_tools() { + install_pkg pwgen pwgen + install_pkg mc mc +} + +set_default_shell() { + zsh_path="$(command -v zsh)" || die "zsh wurde nicht gefunden." + + if [ "${SHELL:-}" = "$zsh_path" ]; then + printf "✓ %-32s bereits Login-Shell\n" "zsh" + return + fi + + printf "→ Setze zsh als Login-Shell (chsh)\n" + chsh -s "$zsh_path" +} + +main() { + check_prerequisites + setup_homebrew_env + + install_plugins + install_tools + set_default_shell + + printf "\nBootstrap abgeschlossen.\n" +} + +main "$@" diff --git a/readme.md b/readme.md index 4b168d3..f4e914e 100644 --- a/readme.md +++ b/readme.md @@ -19,6 +19,12 @@ Bootstrap the Neovim environment: ./bootstrap/neovim-dict.sh ``` +Bootstrap the zsh environment: + +```sh +./bootstrap/zsh.sh +``` + ### Windows Native PowerShell, no WSL/Git Bash required: -- cgit v1.3