refactor(pygmalion): redo and simplify prompt sequences

With this commit we put the minimal needed color resets, i.e. only
when we don't control the previous text we need to do a full reset.
Otherwise we can just use %F{} to change only the foreground color.
This commit is contained in:
Marc Cornellà 2024-07-12 18:14:29 +02:00
commit 7d7d9f05f3
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B

View file

@ -1,16 +1,12 @@
# Yay! High voltage and arrows!
prompt_setup_pygmalion(){
setopt localoptions nopromptsubst extendedglob
ZSH_THEME_GIT_PROMPT_PREFIX="%{${reset_color}%}%F{green}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{${reset_color}%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%F{yellow}⚡%f"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
base_prompt="%{${reset_color}%}%F{magenta}%n%F{cyan}@%F{yellow}%m%F{red}:%F{cyan}%0~%F{red}|%f"
post_prompt="%{${reset_color}%}%F{cyan}⇒%f "
base_prompt='%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
PROMPT="${base_prompt}\$(git_prompt_info)${post_prompt}"
}
prompt_setup_pygmalion
PROMPT="${base_prompt}\$(git_prompt_info)${post_prompt}"
unset base_prompt post_prompt