feat(zsh): provision Oh-My-Zsh and plugins for all users on login

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
2026-09-06 12:30:51 +02:00
co-authored by Junie
parent 28319183b6
commit c4241d7015
5 changed files with 98 additions and 1 deletions
+3
View File
@@ -61,3 +61,6 @@ unrar
unzip unzip
zram-tools zram-tools
zsh zsh
zsh-autosuggestions
zsh-doc
zsh-syntax-highlighting
@@ -1,3 +1,4 @@
#!/bin/sh
# /etc/profile.d/desktop_session_xdg_dirs.sh - Prepend a $DESKTOP_SESSION-named directory to $XDG_CONFIG_DIRS and $XDG_DATA_DIRS # /etc/profile.d/desktop_session_xdg_dirs.sh - Prepend a $DESKTOP_SESSION-named directory to $XDG_CONFIG_DIRS and $XDG_DATA_DIRS
DEFAULT_XDG_CONFIG_DIRS="/etc/xdg" DEFAULT_XDG_CONFIG_DIRS="/etc/xdg"
@@ -49,6 +49,40 @@ mark_as_prompted() {
touch "$MARKER_FILE" 2>/dev/null || true touch "$MARKER_FILE" 2>/dev/null || true
} }
install_oh_my_zsh() {
local zsh_dir="$HOME/.oh-my-zsh"
printf "\n"
printf "%b\n" "${CLR_BOLD}${CLR_CYAN}==============================================================================${CLR_RESET}"
printf "%b\n" "${CLR_BOLD}${CLR_CYAN} Oh-My-Zsh & Shell-Konfiguration ${CLR_RESET}"
printf "%b\n" "${CLR_BOLD}${CLR_CYAN}==============================================================================${CLR_RESET}"
printf "\n"
if [[ ! -d "$zsh_dir" ]]; then
printf "%b\n" "${CLR_CYAN}[INFO] Richte Oh-My-Zsh für $USER ein...${CLR_RESET}"
if command -v git >/dev/null 2>&1; then
if git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "$zsh_dir"; then
mkdir -p "$zsh_dir/custom/plugins"
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "$zsh_dir/custom/plugins/zsh-autosuggestions" 2>/dev/null || true
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting "$zsh_dir/custom/plugins/zsh-syntax-highlighting" 2>/dev/null || true
printf "%b\n" "${CLR_GREEN}[✓] Oh-My-Zsh erfolgreich eingerichtet.${CLR_RESET}"
else
printf "%b\n" "${CLR_YELLOW}[WARNUNG] Oh-My-Zsh konnte nicht geklont werden.${CLR_RESET}"
fi
else
printf "%b\n" "${CLR_RED}[FEHLER] 'git' ist nicht installiert. Oh-My-Zsh konnte nicht eingerichtet werden.${CLR_RESET}"
fi
else
# Plugins sicherstellen
if [[ ! -d "$zsh_dir/custom/plugins/zsh-autosuggestions" ]] && command -v git >/dev/null 2>&1; then
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "$zsh_dir/custom/plugins/zsh-autosuggestions" 2>/dev/null || true
fi
if [[ ! -d "$zsh_dir/custom/plugins/zsh-syntax-highlighting" ]] && command -v git >/dev/null 2>&1; then
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting "$zsh_dir/custom/plugins/zsh-syntax-highlighting" 2>/dev/null || true
fi
printf "%b\n" "${CLR_GREEN}[✓] Oh-My-Zsh ist bereits vorhanden und konfiguriert.${CLR_RESET}"
fi
}
install_junie_cli_and_skills() { install_junie_cli_and_skills() {
printf "\n" printf "\n"
printf "%b\n" "${CLR_BOLD}${CLR_CYAN}==============================================================================${CLR_RESET}" printf "%b\n" "${CLR_BOLD}${CLR_CYAN}==============================================================================${CLR_RESET}"
@@ -308,6 +342,9 @@ while true; do
esac esac
done done
# Oh-My-Zsh & Plugins einrichten
install_oh_my_zsh
# JetBrains Junie CLI & AwesomeJunieSkills installieren # JetBrains Junie CLI & AwesomeJunieSkills installieren
install_junie_cli_and_skills install_junie_cli_and_skills
+21
View File
@@ -3,6 +3,27 @@
export ZSH="$HOME/.oh-my-zsh" export ZSH="$HOME/.oh-my-zsh"
# Automatic Oh-My-Zsh installation on login / shell startup if not yet installed
if [[ ! -d "$ZSH" ]]; then
if command -v git >/dev/null 2>&1; then
echo "Oh-My-Zsh ist nicht eingerichtet. Installiere Oh-My-Zsh für $USER..."
if git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "$ZSH" 2>/dev/null; then
mkdir -p "${ZSH_CUSTOM:-$ZSH/custom}/plugins"
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-$ZSH/custom}/plugins/zsh-autosuggestions" 2>/dev/null || true
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting "${ZSH_CUSTOM:-$ZSH/custom}/plugins/zsh-syntax-highlighting" 2>/dev/null || true
echo "Oh-My-Zsh erfolgreich eingerichtet."
fi
fi
else
# Plugins sicherstellen, falls Oh-My-Zsh existiert aber Custom-Plugins fehlen
if [[ ! -d "${ZSH_CUSTOM:-$ZSH/custom}/plugins/zsh-autosuggestions" ]] && command -v git >/dev/null 2>&1; then
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-$ZSH/custom}/plugins/zsh-autosuggestions" 2>/dev/null || true
fi
if [[ ! -d "${ZSH_CUSTOM:-$ZSH/custom}/plugins/zsh-syntax-highlighting" ]] && command -v git >/dev/null 2>&1; then
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting "${ZSH_CUSTOM:-$ZSH/custom}/plugins/zsh-syntax-highlighting" 2>/dev/null || true
fi
fi
apt_pref='apt' apt_pref='apt'
apt_upgr='upgrade' apt_upgr='upgrade'
+36 -1
View File
@@ -51,6 +51,21 @@ if [[ -d "$SCRIPT_DIR/data/skel/.config" ]]; then
chmod 0755 /etc/skel/.config/hypr/scripts/*.sh 2>/dev/null || true chmod 0755 /etc/skel/.config/hypr/scripts/*.sh 2>/dev/null || true
fi fi
fi fi
# Provision Oh-My-Zsh template in /etc/skel so newly created users receive it automatically
if command_exists git; then
if [[ ! -d /etc/skel/.oh-my-zsh ]]; then
log_info "Provisioning Oh-My-Zsh template in /etc/skel/.oh-my-zsh..."
git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git /etc/skel/.oh-my-zsh 2>/dev/null || log_warn "Could not clone Oh-My-Zsh into /etc/skel."
fi
if [[ -d /etc/skel/.oh-my-zsh ]]; then
mkdir -p /etc/skel/.oh-my-zsh/custom/plugins
[[ -d /etc/skel/.oh-my-zsh/custom/plugins/zsh-autosuggestions ]] || \
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions /etc/skel/.oh-my-zsh/custom/plugins/zsh-autosuggestions 2>/dev/null || true
[[ -d /etc/skel/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting ]] || \
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting /etc/skel/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting 2>/dev/null || true
fi
fi
chown -R root:root /etc/skel chown -R root:root /etc/skel
# 3. Synchronize User Environment for Target User # 3. Synchronize User Environment for Target User
@@ -85,11 +100,23 @@ fi
# 4. Install Oh-My-Zsh for Target User (if not already installed) # 4. Install Oh-My-Zsh for Target User (if not already installed)
if [[ ! -d "$TARGET_HOME/.oh-my-zsh" ]]; then if [[ ! -d "$TARGET_HOME/.oh-my-zsh" ]]; then
log_substep "Installing Oh-My-Zsh repository for $TARGET_USER..." log_substep "Installing Oh-My-Zsh repository for $TARGET_USER..."
if command_exists git; then if [[ -d /etc/skel/.oh-my-zsh ]]; then
cp -r /etc/skel/.oh-my-zsh "$TARGET_HOME/.oh-my-zsh"
elif command_exists git; then
run_as_target_user git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "$TARGET_HOME/.oh-my-zsh" 2>/dev/null || log_warn "Could not clone Oh-My-Zsh repository." run_as_target_user git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "$TARGET_HOME/.oh-my-zsh" 2>/dev/null || log_warn "Could not clone Oh-My-Zsh repository."
fi fi
fi fi
if [[ -d "$TARGET_HOME/.oh-my-zsh" ]]; then
mkdir -p "$TARGET_HOME/.oh-my-zsh/custom/plugins"
if [[ ! -d "$TARGET_HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions" ]] && command_exists git; then
run_as_target_user git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "$TARGET_HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions" 2>/dev/null || true
fi
if [[ ! -d "$TARGET_HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" ]] && command_exists git; then
run_as_target_user git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting "$TARGET_HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" 2>/dev/null || true
fi
fi
# Fix ownership # Fix ownership
chown -R "$TARGET_USER:$TARGET_USER" "$TARGET_HOME/.zshrc" "$TARGET_HOME/Templates" "$TARGET_HOME/.config" "$TARGET_HOME/.junie" chown -R "$TARGET_USER:$TARGET_USER" "$TARGET_HOME/.zshrc" "$TARGET_HOME/Templates" "$TARGET_HOME/.config" "$TARGET_HOME/.junie"
if [[ -d "$TARGET_HOME/.oh-my-zsh" ]]; then if [[ -d "$TARGET_HOME/.oh-my-zsh" ]]; then
@@ -110,6 +137,14 @@ if [[ -x "$ZSH_BIN" ]]; then
else else
log_info "Default shell for $TARGET_USER is already $ZSH_BIN" log_info "Default shell for $TARGET_USER is already $ZSH_BIN"
fi fi
# Configure default shell for newly created users
if command_exists useradd; then
useradd -D -s "$ZSH_BIN" 2>/dev/null || true
fi
if [[ -f /etc/adduser.conf ]]; then
sed -i -E 's|^#?\s*DSHELL=.*|DSHELL='"$ZSH_BIN"'|' /etc/adduser.conf 2>/dev/null || true
fi
else else
log_warn "Zsh binary not found at $ZSH_BIN. Skipping chsh." log_warn "Zsh binary not found at $ZSH_BIN. Skipping chsh."
fi fi