English 中文(简体)
什么是? 意 见
原标题:What does ${#${(S%%)string//(\%([KF1]|){*}|\%[Bbkf])}} mean
  • 时间:2010-02-15 16:04:52
  •  标签:
  • zsh
  • prompt

我在adam2 zsh提示符中找到了它,我不知道它的含义。 显然它计算“字符串”的长度,但它是如何做到的超出了我的理解。

${#${(S%%)string//(\%([KF1]|){*}|\%[Bbkf])}}
最佳回答

I googled “zsh Immediate regex”, and found this。 它说,只有一美元是内容的长度。 这一链接也比zshuser s Guide更为有用。 我发现。

问题回答

你的模式计算在剥离某些ANSI风格的字符格式后字符串的长度。

大约

  • ${# } - 长度

  • ${ } - 嵌套的

  • <代码>(%)——从尾开始的搜索次

  • // - 全局替换(在这种情况下,删除,因为后面没有斜杠)

  • ( )- 捕获组

  • - 字面表示

  • [KF1] - 字符列表:K=开始背景颜色,F=开始前景颜色

  • 【Bbkf】- 字符清单:B=开始加粗,b=结束加粗,k=结束背景,f=结束前景色

然后我迷路了。





相关问题
zsh alias -> function?

Suppose I have: alias gg="git grep" then stuff like: gg "int x" works, but gg int x gets complaints. Is there a way to rewrite gg as a function in zsh so that it takes all the arguments after ...

zsh handling of arguments

In the zsh programming language, how do I get the entire list of arguments as a string in "" ? i.e. in myzshcommand 1 2 3 foo bar I want something to match me "1 2 3 foo bar" Thanks!

Tell if a user has SUed in a shell script?

I have a script which executes a git-pull when I log in. The problem is, if I su to a different user and preserve my environment with an su -lp, the script gets run again and usually gets messed up ...

How do I require a minimum version of zsh?

I want to use a feature only present in newer versions of zsh: [[ "$foo" =~ "regexp" ]] where regexp is a regular expression. Is it possible to do this check? Something like: if [[ $ZSH_VERSION &...

Rename files based on sorted creation date?

I have a directory filled with files with random names. I d like to be able to rename them file 1 file 2 etc based on chronological order, ie file creation date. I could be writing a short Python ...

ZSH Prompt/RPrompt Conflict

I currently have my ZSH PROMPT variable set up as: PROMPT=$ [%{e[0;32m%}%n@%m:%~%{e[0m%}]> and my RPROMPT variable as: RPROMPT=$ [%{e[0;32m%}%Te[0m%}] The effect I m working for is to make ...

热门标签