Add PS2 support to fresh prompt theme
This commit is contained in:
parent
2eb00e4008
commit
aa4d1ddd85
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user