diff options
| author | Thomas Schmucker <ts@its1.de> | 2026-08-12 09:22:12 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2026-08-12 09:22:12 +0200 |
| commit | 189d244d36d4ebb2189b698adb21f51cf1c4176a (patch) | |
| tree | 3a6a9847dafabea051997b1a9cbc124a242ec1d3 /bootstrap/zsh.sh | |
| parent | 6e5882a2fd02d30206ab9ca8aa5847b8ea09196c (diff) | |
| download | dotfiles-189d244d36d4ebb2189b698adb21f51cf1c4176a.tar.gz dotfiles-189d244d36d4ebb2189b698adb21f51cf1c4176a.tar.bz2 dotfiles-189d244d36d4ebb2189b698adb21f51cf1c4176a.zip | |
Revert "Normalize line endings"
This reverts commit 6e5882a2fd02d30206ab9ca8aa5847b8ea09196c.
Diffstat (limited to 'bootstrap/zsh.sh')
| -rwxr-xr-x | bootstrap/zsh.sh | 266 |
1 files changed, 133 insertions, 133 deletions
diff --git a/bootstrap/zsh.sh b/bootstrap/zsh.sh index 8cea3b6..0be7ff3 100755 --- a/bootstrap/zsh.sh +++ b/bootstrap/zsh.sh | |||
| @@ -1,133 +1,133 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | set -eu | 3 | set -eu |
| 4 | 4 | ||
| 5 | OS="$(uname -s)" | 5 | OS="$(uname -s)" |
| 6 | 6 | ||
| 7 | die() { | 7 | die() { |
| 8 | printf 'Fehler: %s\n' "$*" >&2 | 8 | printf 'Fehler: %s\n' "$*" >&2 |
| 9 | exit 1 | 9 | exit 1 |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | have() { | 12 | have() { |
| 13 | command -v "$1" >/dev/null 2>&1 | 13 | command -v "$1" >/dev/null 2>&1 |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | check_prerequisites() { | 16 | check_prerequisites() { |
| 17 | case "$OS" in | 17 | case "$OS" in |
| 18 | Darwin) | 18 | Darwin) |
| 19 | if ! have brew; then | 19 | if ! have brew; then |
| 20 | die "Homebrew ist nicht installiert." | 20 | die "Homebrew ist nicht installiert." |
| 21 | fi | 21 | fi |
| 22 | ;; | 22 | ;; |
| 23 | FreeBSD) | 23 | FreeBSD) |
| 24 | if ! have doas; then | 24 | if ! have doas; then |
| 25 | die "doas ist nicht installiert." | 25 | die "doas ist nicht installiert." |
| 26 | fi | 26 | fi |
| 27 | ;; | 27 | ;; |
| 28 | *) | 28 | *) |
| 29 | die "Nicht unterstütztes Betriebssystem: $OS" | 29 | die "Nicht unterstütztes Betriebssystem: $OS" |
| 30 | ;; | 30 | ;; |
| 31 | esac | 31 | esac |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | setup_homebrew_env() { | 34 | setup_homebrew_env() { |
| 35 | case "$OS" in | 35 | case "$OS" in |
| 36 | Darwin) | 36 | Darwin) |
| 37 | export HOMEBREW_NO_AUTO_UPDATE=1 | 37 | export HOMEBREW_NO_AUTO_UPDATE=1 |
| 38 | export HOMEBREW_NO_INSTALL_CLEANUP=1 | 38 | export HOMEBREW_NO_INSTALL_CLEANUP=1 |
| 39 | ;; | 39 | ;; |
| 40 | esac | 40 | esac |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | install_pkg() { | 43 | install_pkg() { |
| 44 | binary="$1" | 44 | binary="$1" |
| 45 | package="$2" | 45 | package="$2" |
| 46 | 46 | ||
| 47 | if have "$binary"; then | 47 | if have "$binary"; then |
| 48 | printf "✓ %-32s vorhanden\n" "$binary" | 48 | printf "✓ %-32s vorhanden\n" "$binary" |
| 49 | return | 49 | return |
| 50 | fi | 50 | fi |
| 51 | 51 | ||
| 52 | printf "→ Installiere %s\n" "$package" | 52 | printf "→ Installiere %s\n" "$package" |
| 53 | 53 | ||
| 54 | case "$OS" in | 54 | case "$OS" in |
| 55 | Darwin) | 55 | Darwin) |
| 56 | brew install "$package" | 56 | brew install "$package" |
| 57 | ;; | 57 | ;; |
| 58 | FreeBSD) | 58 | FreeBSD) |
| 59 | doas pkg install -y "$package" | 59 | doas pkg install -y "$package" |
| 60 | ;; | 60 | ;; |
| 61 | esac | 61 | esac |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | install_prerequisites() { | 64 | install_prerequisites() { |
| 65 | install_pkg zsh zsh | 65 | install_pkg zsh zsh |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | install_plugin() { | 68 | install_plugin() { |
| 69 | # zsh-syntax-highlighting/zsh-autosuggestions haben kein eigenes Binary, | 69 | # zsh-syntax-highlighting/zsh-autosuggestions haben kein eigenes Binary, |
| 70 | # deshalb Pruefung anhand des von zsh/zshrc gesourceten Pfads. | 70 | # deshalb Pruefung anhand des von zsh/zshrc gesourceten Pfads. |
| 71 | file="$1" | 71 | file="$1" |
| 72 | package="$2" | 72 | package="$2" |
| 73 | 73 | ||
| 74 | if [ -e "$file" ]; then | 74 | if [ -e "$file" ]; then |
| 75 | printf "✓ %-32s vorhanden\n" "$package" | 75 | printf "✓ %-32s vorhanden\n" "$package" |
| 76 | return | 76 | return |
| 77 | fi | 77 | fi |
| 78 | 78 | ||
| 79 | printf "→ Installiere %s\n" "$package" | 79 | printf "→ Installiere %s\n" "$package" |
| 80 | 80 | ||
| 81 | case "$OS" in | 81 | case "$OS" in |
| 82 | Darwin) | 82 | Darwin) |
| 83 | brew install "$package" | 83 | brew install "$package" |
| 84 | ;; | 84 | ;; |
| 85 | FreeBSD) | 85 | FreeBSD) |
| 86 | doas pkg install -y "$package" | 86 | doas pkg install -y "$package" |
| 87 | ;; | 87 | ;; |
| 88 | esac | 88 | esac |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | install_plugins() { | 91 | install_plugins() { |
| 92 | case "$OS" in | 92 | case "$OS" in |
| 93 | Darwin) | 93 | Darwin) |
| 94 | install_plugin "/opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" zsh-syntax-highlighting | 94 | install_plugin "/opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" zsh-syntax-highlighting |
| 95 | install_plugin "/opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh" zsh-autosuggestions | 95 | install_plugin "/opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh" zsh-autosuggestions |
| 96 | ;; | 96 | ;; |
| 97 | FreeBSD) | 97 | FreeBSD) |
| 98 | install_plugin "/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" zsh-syntax-highlighting | 98 | install_plugin "/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" zsh-syntax-highlighting |
| 99 | install_plugin "/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh" zsh-autosuggestions | 99 | install_plugin "/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh" zsh-autosuggestions |
| 100 | ;; | 100 | ;; |
| 101 | esac | 101 | esac |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | install_tools() { | 104 | install_tools() { |
| 105 | install_pkg pwgen pwgen | 105 | install_pkg pwgen pwgen |
| 106 | install_pkg mc mc | 106 | install_pkg mc mc |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | set_default_shell() { | 109 | set_default_shell() { |
| 110 | zsh_path="$(command -v zsh)" || die "zsh wurde nicht gefunden." | 110 | zsh_path="$(command -v zsh)" || die "zsh wurde nicht gefunden." |
| 111 | 111 | ||
| 112 | if [ "${SHELL:-}" = "$zsh_path" ]; then | 112 | if [ "${SHELL:-}" = "$zsh_path" ]; then |
| 113 | printf "✓ %-32s bereits Login-Shell\n" "zsh" | 113 | printf "✓ %-32s bereits Login-Shell\n" "zsh" |
| 114 | return | 114 | return |
| 115 | fi | 115 | fi |
| 116 | 116 | ||
| 117 | printf "→ Setze zsh als Login-Shell (chsh)\n" | 117 | printf "→ Setze zsh als Login-Shell (chsh)\n" |
| 118 | chsh -s "$zsh_path" | 118 | chsh -s "$zsh_path" |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | main() { | 121 | main() { |
| 122 | check_prerequisites | 122 | check_prerequisites |
| 123 | setup_homebrew_env | 123 | setup_homebrew_env |
| 124 | 124 | ||
| 125 | install_prerequisites | 125 | install_prerequisites |
| 126 | install_plugins | 126 | install_plugins |
| 127 | install_tools | 127 | install_tools |
| 128 | set_default_shell | 128 | set_default_shell |
| 129 | 129 | ||
| 130 | printf "\nzsh-Bootstrap abgeschlossen.\n" | 130 | printf "\nzsh-Bootstrap abgeschlossen.\n" |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | main "$@" | 133 | main "$@" |
