pygmalion.zsh-theme 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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. autoload -U add-zsh-hook
  12. add-zsh-hook precmd prompt_pygmalion_precmd
  13. }
  14. prompt_pygmalion_precmd(){
  15. local gitinfo=$(git_prompt_info)
  16. local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
  17. local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
  18. local prompt_length=${#exp_nocolor}
  19. local nl=""
  20. if [[ $prompt_length -gt 40 ]]; then
  21. nl=$'\n%{\r%}';
  22. fi
  23. PROMPT="$base_prompt$gitinfo$nl$post_prompt"
  24. }
  25. prompt_setup_pygmalion