af-magic.zsh-theme 1.6 KB

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