Add RPS1 support to fresh prompt theme

* Python virtualenv name
* Docker machine name
This commit is contained in:
Kenneth Benzie 2017-11-29 15:51:39 +00:00
parent e58b9ba032
commit 85d5d549a5

View File

@ -19,7 +19,7 @@ prompt_fresh_setup() {
PS1="«$user» " PS1="«$user» "
PS2="${(l:$length + 1:: :)}» " PS2="${(l:$length + 1:: :)}» "
# TODO: RPS1 RPS1='$(fresh_rprompt)'
prompt_opts=(cr percent sp subst) prompt_opts=(cr percent sp subst)
} }
@ -104,6 +104,17 @@ fresh_precmd() {
fi fi
} }
fresh_rprompt() {
rprompt=""
if [[ ! -z "$DOCKER_MACHINE_NAME" ]]; then
rprompt="$rprompt %{%F{3}%}$DOCKER_MACHINE_NAME%{%f%}"
fi
if [[ ! -z "$VIRTUAL_ENV" ]]; then
rprompt="$rprompt %{%F{3}%}$(basename $VIRTUAL_ENV)%{%f%}"
fi
echo $rprompt
}
visible_length() { visible_length() {
echo $(( ${#${(S%%)1//(\%(KF1]|)\{*\}|\%[Bbkf])}} )) echo $(( ${#${(S%%)1//(\%(KF1]|)\{*\}|\%[Bbkf])}} ))
} }