Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: non-greedy matching?
- X-seq: zsh-users 3716
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh users mailing list <zsh-users@xxxxxxxxxxxxxx>
- Subject: Re: non-greedy matching?
- Date: Wed, 21 Mar 2001 16:01:16 +0000
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20010321142303.B8924@xxxxxxxxxxxxxxxxxxxxxxx> <20010321151448.4320.qmail@xxxxxxxxxxxxxxxxxxxxxx>
On Mar 21, 2:23pm, Adam Spiers wrote:
} Subject: non-greedy matching?
}
} ..... | perl -pe 's/%{.*?%}//g'
}
} They are done in order to strip control characters from a prompt so
} that its display width can be determined.
I had to do something similar in prompt_bart_setup, and ended up with
this:
${#${(%%f)${PS1//[%]\{[^%]#%\}/}}[1]}
The (f) and [1] are because of the multi-line PS1, where it computes the
length only of the first line. The above works as long as you don't
have other prompt escapes inside the %{ %}. Hmm. Perhaps this:
${#${(%%)${prompt_line_1a//[%]\{([^%]|%[^\}])#%\}/}}}
Looking at prompt_adam2_precmd, it does exactly what prompt_bart_precmd
does: compute a padding width by subtracting from $COLUMNS. With the
above expression you can get rid of prompt_line_1[ab]_no_color entirely:
prompt_padding_size=$(( COLUMNS
- ${#${(%%)${prompt_line_1a//[%]\{([^%]|%[^\}])#%\}/}}}
- ${#${(%%)${prompt_line_1b//[%]\{([^%]|%[^\}])#%\}/}}} ))
Which also, as Sven mentioned, gets rid of $(print -P ...).
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author