#!/usr/bin/env zsh # ── theme.zsh : starship prompt + transience + engagement banner ───────────── # Rosé Pine sudo prompt: Love label, Text copy, Iris user, and Gold chevron. # The password remains masked; sudoers controls the visible feedback markers. if [[ $OSTYPE == linux* ]]; then export SUDO_PROMPT=$'\e[38;2;235;111;146m[sudo]\e[0m \e[38;2;224;222;244mpassword for \e[38;2;196;167;231m%p\e[0m \e[38;2;246;193;119m❯\e[0m ' fi if (( $+commands[starship] )); then eval "$(starship init zsh)" # ── transient prompt ─────────────────────────────────────────────────────── # starship has NO native zsh transient prompt (enable_transience is a fish/p10k # thing — the old call here was a silent no-op). This collapses each ACCEPTED # command to a slim arrow so scrollback stays clean, while the LIVE prompt keeps # the full capsule frame. starship's precmd rebuilds $PROMPT every line, so the # next prompt is full again automatically. # disable with: STARSHIP_TRANSIENT=0 (set before a new shell) if [[ ${STARSHIP_TRANSIENT:-1} == 1 ]]; then autoload -Uz add-zle-hook-widget add-zsh-hook # starship sets PROMPT/RPROMPT ONCE to a $(starship prompt …) substitution and # never reassigns them in precmd. So the transient must SAVE them and RESTORE on # every new line — otherwise the slim overwrite is permanent and eats the full # prompt for the rest of the session. typeset -g _STARSHIP_PROMPT_FULL="$PROMPT" _STARSHIP_RPROMPT_FULL="$RPROMPT" _starship_restore_prompt() { # precmd: bring the full prompt back PROMPT="$_STARSHIP_PROMPT_FULL" RPROMPT="$_STARSHIP_RPROMPT_FULL" } add-zsh-hook precmd _starship_restore_prompt _starship_transient() { # line-finish: collapse the just-run prompt PROMPT='%F{#9ccfd8}❯%f ' # foam arrow — pine (#31748f) is only # 3.3:1 on the #191724 base and the # collapsed arrow disappeared in # scrollback. foam clears 10.3:1. RPROMPT='' zle && zle .reset-prompt } # add-zle-hook-widget STACKS (won't clobber atuin / syntax-highlighting). add-zle-hook-widget line-finish _starship_transient 2>/dev/null fi else print -P "%F{yellow}%f starship not found — install: brew install starship" fi # Non-invasive active-target indicator: a thin line printed ABOVE the prompt, # only while an htbbox target is set. Reads htbbox's state files (the same ones # that export $TARGET/$BOX), so `htbbox clear` makes it disappear. # Zero changes to your starship.toml. _pentest_target_banner() { local d="${XDG_STATE_HOME:-$HOME/.local/state}/htb" ip box [[ -s $d/target ]] || return 0 ip=$(<"$d/target"); [[ -s $d/box ]] && box=$(<"$d/box") print -P "%F{red}\uf05b%f %F{red}${box:-target}%f %F{8}╴%f %F{cyan}${ip}%f" } autoload -Uz add-zsh-hook add-zsh-hook precmd _pentest_target_banner