What does ${#${(S%%)string//(\%([KF1]|)\{*\}|\%[Bbkf])}} mean
I found this in the adam2 zsh prompt, and I have no idea what it means. Apparently it counts the length of the "string", but how it does that is beyond me.
${#${(S%%)string//(\%([K开发者_JAVA百科F1]|)\{*\}|\%[Bbkf])}}
Your pattern counts the length of the string after stripping out some ANSI-style character formatting.
Approximately:
${# }- length${ }- nested(S%%)- search substrings starting from the end//- substitute globally (in this case delete, since there's no slash later)( )- capture group\%- literal percent sign[KF1]- character list: K=begin background color, F=begin foreground color[Bbkf]- character list: B=begin bold, b=end bold, k=end background, f=end foreground
And then I get lost.
I googled "zsh prompt regex", and found this. It says $# counts the length of the contents. That link also has more info than the zsh user's guide I found.
加载中,请稍侯......
精彩评论