如何在 zsh bindkey 中反斜杠反斜杠?
我想将密钥替换为这样:
bindkey -s ',;' "| grep -A5 \"^\\s{3,}-\"\ei"
在我的 zshrc 中,但是 \\s
部分(对于 PCRE 中的空间应该是 \s
),给出类似这样的内容:
| grep -A5 "^S{3,}-"
所以有一些垃圾而不是\s
。那么我怎样才能实现反斜杠呢?
I would like to replace the key as this:
bindkey -s ',;' "| grep -A5 \"^\\s{3,}-\"\ei"
in my zshrc, but the \\s
part (which should be \s
for space in PCRE), gives something like this:
| grep -A5 "^S{3,}-"
so there is some garbage instead of \s
. So how can I achieve the backslash?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然可能得到正确的引用,但通常最好首先避免这种嵌套引用。首先将 shell 函数添加到您的
.zshrc
文件中:然后让您的小部件插入该函数。
While it's possible to get the quoting right, it's usually better to avoid such nested quoting in the first place. Add a shell function to your
.zshrc
file first:Then have your widget insert the function instead.