mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-03 22:32:12 +02:00
Strip %[BSubsu] as well as %{*%} before computing width of prompt.
This commit is contained in:
parent
a8e2e327d1
commit
9e3017721e
1 changed files with 6 additions and 6 deletions
|
@ -59,6 +59,7 @@ prompt_bart_help () {
|
||||||
|
|
||||||
prompt_bart_precmd () {
|
prompt_bart_precmd () {
|
||||||
setopt localoptions noxtrace noksharrays
|
setopt localoptions noxtrace noksharrays
|
||||||
|
local zero='%([BSUbsu]|{*%})'
|
||||||
|
|
||||||
# Using psvar here protects against unwanted promptsubst expansions.
|
# Using psvar here protects against unwanted promptsubst expansions.
|
||||||
|
|
||||||
|
@ -67,11 +68,10 @@ prompt_bart_precmd () {
|
||||||
|
|
||||||
# Compute the size of the upper left prompt and set psvar[9] if needed.
|
# Compute the size of the upper left prompt and set psvar[9] if needed.
|
||||||
psvar[9]=()
|
psvar[9]=()
|
||||||
((${#${(f)${(%%)${(S)PS1//[%]\{*%\}/}}}[1]} > COLUMNS-2)) && psvar[9]=''
|
((${#${(f)${(%%)${(S)PS1//$~zero/}}}[1]} > COLUMNS-1)) && psvar[9]=''
|
||||||
: ${(S)PS1//[%]\{*%\}/} # Bug workaround, up to 4.0.1-pre-3
|
|
||||||
|
|
||||||
# Compute and set the padding between upper left and right prompts.
|
# Compute and set the padding between upper left and right prompts.
|
||||||
psvar[8]=${(l:COLUMNS-${#${(f)${(%%)${(S)PS1//[%]\{*%\}/}}}[1]}-1:: :)}
|
psvar[8]=${(l:COLUMNS-${#${(f)${(%%)${(S)PS1//$~zero/}}}[1]}-1:: :)}
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_bart_ps1 () {
|
prompt_bart_ps1 () {
|
||||||
|
@ -96,14 +96,14 @@ prompt_bart_ps1 () {
|
||||||
|
|
||||||
# Assemble the new prompt
|
# Assemble the new prompt
|
||||||
ps1=( ${(f)PS1} ) # Split the existing prompt at newlines
|
ps1=( ${(f)PS1} ) # Split the existing prompt at newlines
|
||||||
ps1=( "%$[COLUMNS-3]>..>" # Begin truncation (upper left prompt)
|
ps1=( "%$[COLUMNS-1]>..>" # Begin truncation (upper left prompt)
|
||||||
"$host"
|
"$host"
|
||||||
"$hist1" # Empty when too wide for one line
|
"$hist1" # Empty when too wide for one line
|
||||||
"$dir"
|
"$dir"
|
||||||
"%<<" # End truncation (end upper left prompt)
|
"%<<" # End truncation (end upper left prompt)
|
||||||
"$space" # Pad line to upper right position
|
"$space" # Pad line to upper right position
|
||||||
"%$[COLUMNS-16](l. . $date)"
|
"%$[COLUMNS-16](l. . $date)"
|
||||||
"%$[COLUMNS-6](l.. $time)"
|
"%$[COLUMNS-8](l.. $time)"
|
||||||
"$hist2" # Empty when $hist1 is not empty
|
"$hist2" # Empty when $hist1 is not empty
|
||||||
$'\n'
|
$'\n'
|
||||||
$ps1[-1] ) # Keep last line of the existing prompt
|
$ps1[-1] ) # Keep last line of the existing prompt
|
||||||
|
|
Loading…
Reference in a new issue