pygmalion-virtualenv.zsh-theme 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. setopt localoptions extendedglob
  18. ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
  19. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
  20. ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
  21. ZSH_THEME_GIT_PROMPT_CLEAN=""
  22. 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%}'
  23. post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
  24. base_prompt_nocolor=${base_prompt//\%\{[^\}]##\}}
  25. post_prompt_nocolor=${post_prompt//\%\{[^\}]##\}}
  26. autoload -U add-zsh-hook
  27. add-zsh-hook precmd prompt_pygmalion_precmd
  28. }
  29. prompt_pygmalion_precmd(){
  30. setopt localoptions extendedglob
  31. local gitinfo=$(git_prompt_info)
  32. local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
  33. local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
  34. local prompt_length=${#exp_nocolor}
  35. local nl=""
  36. if [[ $prompt_length -gt 40 ]]; then
  37. nl=$'\n%{\r%}';
  38. fi
  39. PROMPT="$base_prompt$gitinfo$nl$post_prompt"
  40. }
  41. prompt_setup_pygmalion