Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [tip] mouse support



On Thu, 11 Nov 2004, Stephane Chazelas wrote:

> zero='%([BSUbsu]|{*%})'
> 
> It replaces '%%some %{%{some%}%}' with '%ome %}' instead of
> '%%some '

Hmm.  To fix that, you need extended globbing:

setopt extendedglob
zero='(#b)([^%]|(#s))%([BSUbsu]|{*%})'
print ${(%%)PS1//$~zero/$match[1]}

On Thu, 11 Nov 2004, Stephane Chazelas wrote:

> Well the (%%) expansion flag has another problem:
> 
> var='%Sfoo%s'
> PS1='$var'
> 
> In that case, you need to expand first the variables in PS1 or
> you'll miss the %S %s visual sequences.

That's easy enough:

if [[ -o promptsubst ]]
then print ${(%%)${(e)PS1}//$~zero/$match[1]}
else print ${(%%)PS1//$~zero/$match[1]}
fi



Messages sorted by: Reverse Date, Date, Thread, Author