Parent directory

af-magic.zsh-theme

1721 bytes
 1# af-magic.zsh-theme
 2#
 3# Author: Andy Fleming
 4# URL: http://andyfleming.com/
 5
 6# dashed separator size
 7function 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} - 3 ))
18  else
19    echo $COLUMNS
20  fi
21}
22
23# primary prompt: dashed separator, directory and vcs info
24PS1="${FG[237]}\${(l.\$(afmagic_dashes)..-.)}%{$reset_color%}
25${FG[032]}%~\$(git_prompt_info)\$(hg_prompt_info) ${FG[105]}%(!.#.»)%{$reset_color%} "
26PS2="%{$fg[red]%}\ %{$reset_color%}"
27
28# right prompt: return code, virtualenv and context (user@host)
29RPS1="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
30if (( $+functions[virtualenv_prompt_info] )); then
31  RPS1+='$(virtualenv_prompt_info)'
32fi
33RPS1+=" ${FG[237]}%n@%m%{$reset_color%}"
34
35# git settings
36ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
37ZSH_THEME_GIT_PROMPT_CLEAN=""
38ZSH_THEME_GIT_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
39ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
40
41# hg settings
42ZSH_THEME_HG_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
43ZSH_THEME_HG_PROMPT_CLEAN=""
44ZSH_THEME_HG_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
45ZSH_THEME_HG_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
46
47# virtualenv settings
48ZSH_THEME_VIRTUALENV_PREFIX=" ${FG[075]}["
49ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"