From aa4d1ddd8546b46df7bdf245c2049e3f8f7b02cd Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 22 Nov 2017 17:40:47 +0000 Subject: [PATCH] Add PS2 support to fresh prompt theme --- prompt_fresh_setup | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/prompt_fresh_setup b/prompt_fresh_setup index 44769d0..ff16af4 100644 --- a/prompt_fresh_setup +++ b/prompt_fresh_setup @@ -1,6 +1,10 @@ +visible_length() { + echo $(( ${#${(S%%)1//(\%(KF1]|)\{*\}|\%[Bbkf])}} )) +} + prompt_fresh_setup() { autoload -U add-zsh-hook - add-zsh-hook precmd prompt_fresh_precmd + add-zsh-hook precmd fresh_precmd if [ "$USERNAME" = "root" ]; then local user="%{%F{9}%}%n%{%f%}" @@ -12,16 +16,17 @@ prompt_fresh_setup() { local user="%{%F{35}%}$user%{%f%}@%{%F{244}%}%M%{%f%}" fi + local length=`visible_length "$user"` + PS1="«$user» " - # TODO: PS2 - # TODO: PS3 - # TODO: PS4 + PS2="${(l:$length + 1:: :)}» " + # TODO: RPS1 - prompt_opts=(cr subst percent) + prompt_opts=(cr sp subst percent) } -prompt_fresh_precmd() { +fresh_precmd() { local exit_code=$? if [[ $exit_code -ne 0 ]]; then local result="%{%B%F{1}%}$exit_code%{%f%b%}" @@ -34,7 +39,6 @@ prompt_fresh_precmd() { local line="$time_stamp $directory" - visible_length() { echo $(( ${#${(S%%)1//(\%(KF1]|)\{*\}|\%[Bbkf])}} )) } local length=`visible_length "$line$result"` print -P "$line${(l:COLUMNS - $length - 1:: :)}$result"