pygmalion.zsh-theme 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Yay! High voltage and arrows!
  2. prompt_setup_pygmalion(){
  3. ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
  4. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
  5. ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
  6. ZSH_THEME_GIT_PROMPT_CLEAN=""
  7. 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%}'
  8. post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
  9. base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
  10. post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
  11. precmd_functions+=(prompt_pygmalion_precmd)
  12. }
  13. prompt_pygmalion_precmd(){
  14. local gitinfo=$(git_prompt_info)
  15. local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
  16. local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
  17. local prompt_length=${#exp_nocolor}
  18. local nl=""
  19. if [[ $prompt_length -gt 40 ]]; then
  20. nl=$'\n%{\r%}';
  21. fi
  22. PROMPT="$base_prompt$gitinfo$nl$post_prompt"
  23. }
  24. prompt_setup_pygmalion