af-magic.zsh-theme 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # af-magic.zsh-theme
  2. #
  3. # Author: Andy Fleming
  4. # URL: http://andyfleming.com/
  5. # dashed separator size
  6. function afmagic_dashes {
  7. # check either virtualenv or condaenv variables
  8. local python_env="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
  9. # if there is a python virtual environment and it is displayed in
  10. # the prompt, account for it when returning the number of dashes
  11. if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
  12. echo $(( COLUMNS - ${#python_env} - 3 ))
  13. else
  14. echo $COLUMNS
  15. fi
  16. }
  17. # primary prompt: dashed separator, directory and vcs info
  18. PS1="${FG[237]}\${(l.\$(afmagic_dashes)..-.)}%{$reset_color%}
  19. ${FG[032]}%~\$(git_prompt_info)\$(hg_prompt_info) ${FG[105]}%(!.#.»)%{$reset_color%} "
  20. PS2="%{$fg[red]%}\ %{$reset_color%}"
  21. # right prompt: return code, virtualenv and context (user@host)
  22. RPS1="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
  23. if (( $+functions[virtualenv_prompt_info] )); then
  24. RPS1+='$(virtualenv_prompt_info)'
  25. fi
  26. RPS1+=" ${FG[237]}%n@%m%{$reset_color%}"
  27. # git settings
  28. ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
  29. ZSH_THEME_GIT_PROMPT_CLEAN=""
  30. ZSH_THEME_GIT_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
  31. ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
  32. # hg settings
  33. ZSH_THEME_HG_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
  34. ZSH_THEME_HG_PROMPT_CLEAN=""
  35. ZSH_THEME_HG_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
  36. ZSH_THEME_HG_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
  37. # virtualenv settings
  38. ZSH_THEME_VIRTUALENV_PREFIX=" ${FG[075]}["
  39. ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"