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