This commit is contained in:
2026-05-16 20:44:59 +02:00
parent d99cba6bf9
commit 889de1befd
+36 -34
View File
@@ -645,55 +645,58 @@ configure_zsh_ohmyzsh_powerlevel10k() {
log "Oh My Zsh is already installed." log "Oh My Zsh is already installed."
fi fi
zsh_custom="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}" zsh_custom="$HOME/.oh-my-zsh/custom"
p10k_dir="$zsh_custom/themes/powerlevel10k" p10k_dir="$zsh_custom/themes/powerlevel10k"
mkdir -p "$zsh_custom/themes"
if [[ -d "$p10k_dir/.git" ]]; then if [[ -d "$p10k_dir/.git" ]]; then
log "Powerlevel10k already exists. Updating..." log "Powerlevel10k already exists. Updating..."
git -C "$p10k_dir" pull --ff-only || warn "Could not update Powerlevel10k. Continuing with existing copy." git -C "$p10k_dir" pull --ff-only || warn "Could not update Powerlevel10k. Continuing with existing copy."
else else
log "Installing Powerlevel10k..." log "Installing Powerlevel10k into $p10k_dir..."
rm -rf "$p10k_dir"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$p10k_dir" git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$p10k_dir"
fi fi
if [[ -f "$HOME/.zshrc" ]] && ! grep -q "powerlevel10k/powerlevel10k" "$HOME/.zshrc"; then if [[ ! -f "$p10k_dir/powerlevel10k.zsh-theme" ]]; then
cp "$HOME/.zshrc" "$HOME/.zshrc.backup.$(date +%Y%m%d%H%M%S)" warn "Powerlevel10k theme file was not found after installation: $p10k_dir/powerlevel10k.zsh-theme"
return
fi fi
if [[ -f "$HOME/.zshrc" ]]; then if [[ -f "$HOME/.zshrc" ]]; then
tmp_zshrc="$(mktemp)" cp "$HOME/.zshrc" "$HOME/.zshrc.backup.$(date +%Y%m%d%H%M%S)"
grep -v "POWERLEVEL9K_INSTANT_PROMPT" "$HOME/.zshrc" > "$tmp_zshrc" || true
{
echo "typeset -g POWERLEVEL9K_INSTANT_PROMPT=off"
cat "$tmp_zshrc"
} > "$HOME/.zshrc"
rm -f "$tmp_zshrc"
fi fi
if [[ ! -f "$HOME/.zshrc" ]]; then # Keep the zshrc deterministic. This avoids Oh My Zsh loading before ZSH_CUSTOM
cat > "$HOME/.zshrc" <<ZSHRC # is defined, which causes: theme 'powerlevel10k/powerlevel10k' not found.
export ZSH="\$HOME/.oh-my-zsh" cat > "$HOME/.zshrc" <<'ZSHRC'
ZSH_THEME="powerlevel10k/powerlevel10k" # Disable Powerlevel10k instant prompt because this setup intentionally prints
plugins=(git sudo) # Fastfetch system information at terminal startup.
source "\$ZSH/oh-my-zsh.sh" typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
export ZSH="$HOME/.oh-my-zsh"
ZSH_CUSTOM="$ZSH/custom"
ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(
git
sudo
)
source "$ZSH/oh-my-zsh.sh"
# Jose fastfetch terminal summary
# Disable with: export DISABLE_FASTFETCH=1
if [[ -o interactive ]] && [[ -z "${DISABLE_FASTFETCH:-}" ]] && [[ -z "${FASTFETCH_SHOWN:-}" ]] && command -v fastfetch >/dev/null 2>&1; then
export FASTFETCH_SHOWN=1
fastfetch
echo
fi
# Powerlevel10k user config.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
ZSHRC ZSHRC
else
if grep -q "^ZSH_THEME=" "$HOME/.zshrc"; then
sed -i "s|^ZSH_THEME=.*|ZSH_THEME=\"powerlevel10k/powerlevel10k\"|" "$HOME/.zshrc"
else
printf "\nZSH_THEME=\"powerlevel10k/powerlevel10k\"\n" >> "$HOME/.zshrc"
fi
if ! grep -q "oh-my-zsh.sh" "$HOME/.zshrc"; then
printf "\nexport ZSH=\"\$HOME/.oh-my-zsh\"\nsource \"\$ZSH/oh-my-zsh.sh\"\n" >> "$HOME/.zshrc"
fi
if ! grep -q ".p10k.zsh" "$HOME/.zshrc"; then
printf "\n[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh\n" >> "$HOME/.zshrc"
fi
fi
current_shell="$(getent passwd "$USER" | cut -d: -f7 || true)" current_shell="$(getent passwd "$USER" | cut -d: -f7 || true)"
zsh_path="$(command -v zsh)" zsh_path="$(command -v zsh)"
@@ -706,10 +709,9 @@ ZSHRC
fi fi
log "Zsh + Oh My Zsh + Powerlevel10k configured." log "Zsh + Oh My Zsh + Powerlevel10k configured."
warn "Open Ghostty after reboot/login. Powerlevel10k will start its configuration wizard the first time." warn "Open Ghostty after reboot/login. Run 'p10k configure' if you want to customize the prompt."
} }
configure_wireguard_gui_webkit_workaround() { configure_wireguard_gui_webkit_workaround() {
log "Configuring WireGuard GUI WebKit renderer workaround..." log "Configuring WireGuard GUI WebKit renderer workaround..."