2012-06-20 20:17:41 +00:00
|
|
|
# af-magic.zsh-theme
|
2021-11-30 17:07:42 +00:00
|
|
|
#
|
|
|
|
# Author: Andy Fleming
|
|
|
|
# URL: http://andyfleming.com/
|
2012-06-20 20:17:41 +00:00
|
|
|
|
2021-11-30 17:07:42 +00:00
|
|
|
# dashed separator size
|
2020-02-18 18:14:30 +00:00
|
|
|
function afmagic_dashes {
|
2021-11-30 17:07:42 +00:00
|
|
|
# check either virtualenv or condaenv variables
|
2024-03-06 21:06:53 +00:00
|
|
|
local python_env_dir="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
|
|
|
|
local python_env="${python_env_dir##*/}"
|
|
|
|
|
2021-11-30 17:07:42 +00:00
|
|
|
# if there is a python virtual environment and it is displayed in
|
|
|
|
# the prompt, account for it when returning the number of dashes
|
2024-03-06 21:06:53 +00:00
|
|
|
if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
|
2021-11-30 17:07:42 +00:00
|
|
|
echo $(( COLUMNS - ${#python_env} - 3 ))
|
|
|
|
else
|
|
|
|
echo $COLUMNS
|
|
|
|
fi
|
2020-02-18 18:14:30 +00:00
|
|
|
}
|
2012-06-20 20:17:41 +00:00
|
|
|
|
2021-11-30 17:07:42 +00:00
|
|
|
# primary prompt: dashed separator, directory and vcs info
|
|
|
|
PS1="${FG[237]}\${(l.\$(afmagic_dashes)..-.)}%{$reset_color%}
|
|
|
|
${FG[032]}%~\$(git_prompt_info)\$(hg_prompt_info) ${FG[105]}%(!.#.»)%{$reset_color%} "
|
|
|
|
PS2="%{$fg[red]%}\ %{$reset_color%}"
|
2012-06-20 20:17:41 +00:00
|
|
|
|
2021-11-30 17:07:42 +00:00
|
|
|
# right prompt: return code, virtualenv and context (user@host)
|
|
|
|
RPS1="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
|
|
|
if (( $+functions[virtualenv_prompt_info] )); then
|
|
|
|
RPS1+='$(virtualenv_prompt_info)'
|
|
|
|
fi
|
|
|
|
RPS1+=" ${FG[237]}%n@%m%{$reset_color%}"
|
2012-06-20 20:17:41 +00:00
|
|
|
|
2012-06-20 20:26:05 +00:00
|
|
|
# git settings
|
2020-10-28 17:31:26 +00:00
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
|
2012-06-20 20:17:41 +00:00
|
|
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
2021-11-30 17:07:42 +00:00
|
|
|
ZSH_THEME_GIT_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
|
2024-03-06 20:54:44 +00:00
|
|
|
ZSH_THEME_GIT_PROMPT_STASH="${FG[214]}\$"
|
|
|
|
ZSH_THEME_GIT_RESET_COLOR="%{$reset_color%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_STASH_DIRTY="${FG[214]}*\$"
|
2021-11-30 17:07:42 +00:00
|
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
|
2019-08-19 16:54:49 +00:00
|
|
|
|
|
|
|
# hg settings
|
2020-10-28 17:31:26 +00:00
|
|
|
ZSH_THEME_HG_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
|
2019-08-19 16:54:49 +00:00
|
|
|
ZSH_THEME_HG_PROMPT_CLEAN=""
|
2021-11-30 17:07:42 +00:00
|
|
|
ZSH_THEME_HG_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
|
|
|
|
ZSH_THEME_HG_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
|
2020-02-18 18:14:30 +00:00
|
|
|
|
|
|
|
# virtualenv settings
|
2021-11-30 17:07:42 +00:00
|
|
|
ZSH_THEME_VIRTUALENV_PREFIX=" ${FG[075]}["
|
2020-02-18 21:28:58 +00:00
|
|
|
ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"
|