pygmalion-virtualenv.zsh-theme 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Yay! High voltage and arrows!
  2. function _virtualenv_prompt_info {
  3. if [[ -n "$(whence virtualenv_prompt_info)" ]]; then
  4. if [ -n "$(whence pyenv_prompt_info)" ]; then
  5. if [ "$1" = "inline" ]; then
  6. ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX=%{$fg[blue]%}"::%{$fg[red]%}"
  7. ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX=""
  8. virtualenv_prompt_info
  9. fi
  10. [ "$(pyenv_prompt_info)" = "${PYENV_PROMPT_DEFAULT_VERSION}" ] && virtualenv_prompt_info
  11. else
  12. virtualenv_prompt_info
  13. fi
  14. fi
  15. }
  16. prompt_setup_pygmalion(){
  17. ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
  18. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
  19. ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
  20. ZSH_THEME_GIT_PROMPT_CLEAN=""
  21. base_prompt='$(_virtualenv_prompt_info)%{$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%}'
  22. post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
  23. base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
  24. post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
  25. precmd_functions+=(prompt_pygmalion_precmd)
  26. }
  27. prompt_pygmalion_precmd(){
  28. local gitinfo=$(git_prompt_info)
  29. local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
  30. local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
  31. local prompt_length=${#exp_nocolor}
  32. local nl=""
  33. if [[ $prompt_length -gt 40 ]]; then
  34. nl=$'\n%{\r%}';
  35. fi
  36. PROMPT="$base_prompt$gitinfo$nl$post_prompt"
  37. }
  38. prompt_setup_pygmalion