From 85d5d549a55b44a9fc664c17d581338d2ab3aa00 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 29 Nov 2017 15:51:39 +0000 Subject: [PATCH] Add RPS1 support to fresh prompt theme * Python virtualenv name * Docker machine name --- prompt_fresh_setup | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/prompt_fresh_setup b/prompt_fresh_setup index dd9cdc6..9efa9fb 100644 --- a/prompt_fresh_setup +++ b/prompt_fresh_setup @@ -19,7 +19,7 @@ prompt_fresh_setup() { PS1="«$user» " PS2="${(l:$length + 1:: :)}» " - # TODO: RPS1 + RPS1='$(fresh_rprompt)' prompt_opts=(cr percent sp subst) } @@ -104,6 +104,17 @@ fresh_precmd() { 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() { echo $(( ${#${(S%%)1//(\%(KF1]|)\{*\}|\%[Bbkf])}} )) }