2012-06-20 22:17:41 +02:00
|
|
|
# af-magic.zsh-theme
|
2021-11-30 18:07:42 +01:00
|
|
|
#
|
|
|
|
# Author: Andy Fleming
|
|
|
|
# URL: http://andyfleming.com/
|
2012-06-20 22:17:41 +02:00
|
|
|
|
2021-11-30 18:07:42 +01:00
|
|
|
# dashed separator size
|
2020-02-18 19:14:30 +01:00
|
|
|
function afmagic_dashes {
|
2021-11-30 18:07:42 +01:00
|
|
|
# check either virtualenv or condaenv variables
|
|
|
|
local python_env="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
|
|
|
|
|
|
|
|
# if there is a python virtual environment and it is displayed in
|
|
|
|
# the prompt, account for it when returning the number of dashes
|
|
|
|
if [[ -n "$python_env" && "$PS1" = \(* ]]; then
|
|
|
|
echo $(( COLUMNS - ${#python_env} - 3 ))
|
|
|
|
else
|
|
|
|
echo $COLUMNS
|
|
|
|
fi
|
2020-02-18 19:14:30 +01:00
|
|
|
}
|
2012-06-20 22:17:41 +02:00
|
|
|
|
2021-11-30 18:07:42 +01: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 22:17:41 +02:00
|
|
|
|
2021-11-30 18:07:42 +01: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 22:17:41 +02:00
|
|
|
|
2012-06-20 22:26:05 +02:00
|
|
|
# git settings
|
2020-10-28 18:31:26 +01:00
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
|
2012-06-20 22:17:41 +02:00
|
|
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
2021-11-30 18:07:42 +01:00
|
|
|
ZSH_THEME_GIT_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
|
|
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
|
2019-08-19 18:54:49 +02:00
|
|
|
|
|
|
|
# hg settings
|
2020-10-28 18:31:26 +01:00
|
|
|
ZSH_THEME_HG_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
|
2019-08-19 18:54:49 +02:00
|
|
|
ZSH_THEME_HG_PROMPT_CLEAN=""
|
2021-11-30 18:07:42 +01:00
|
|
|
ZSH_THEME_HG_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
|
|
|
|
ZSH_THEME_HG_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
|
2020-02-18 19:14:30 +01:00
|
|
|
|
|
|
|
# virtualenv settings
|
2021-11-30 18:07:42 +01:00
|
|
|
ZSH_THEME_VIRTUALENV_PREFIX=" ${FG[075]}["
|
2020-02-18 22:28:58 +01:00
|
|
|
ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"
|