Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
851 views
in Technique[技术] by (71.8m points)

zsh - 如何在不区分大小写的情况下从文件名中间获取匹配的zsh补全?(How do I get zsh completion to match from the middle of a filename ignoring case?)

I am having difficulty getting zsh to autocomplete the way that I would like it to.

(我很难让zsh自动完成我想要的方式。)

Ideally, I would like type some string (that could be a single character), and after hitting tab, get a list of every file and directory that has that string in it, ignoring case.

(理想情况下,我想输入一些字符串(可以是单个字符),然后在按Tab键后,获取其中包含该字符串的每个文件和目录的列表,而忽略大小写。)

I thought my current configuration should do that, but it fails on a few file names.

(我以为我当前的配置应该这样做,但是它在几个文件名上失败了。)

Here is what I am using:

(这是我正在使用的:)

zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'm:{a-zA-Z}={A-Za-z} r:|[._-]=* r:|=*' 'l:|=* r:|=*'

The files that it fails on match *a[0-9]+b[0-9]+* .

(匹配失败的文件*a[0-9]+b[0-9]+* 。)

I would like to be able to type b and hit tab, and see all files that would match that regex.

(我希望能够输入b并点击tab,并查看所有与该正则表达式匹配的文件。)

However, my current configuration displays no results.

(但是,我当前的配置未显示任何结果。)

For example, if I have a directory like this:

(例如,如果我有一个这样的目录:)

$ ls
x-a5b8.y
x.y-a111b82_z
x y.a0b44-z

Typing something and hitting tab should give the following results

(键入内容并单击选项卡应给出以下结果)

$ b[tab]
x-a5b8.y
x.y-a111b82_z
x y.a0b44-z

$ b8[tab]
x-a5b8.y
x.y-a111b82_z

I looked at the docs for Completion Matching Control, but I was unable to figure out what specifically I need to do.

(我查看了“完成匹配控制”的文档 ,但无法弄清具体需要做什么。)

If possible, I would love to use something like regexr to see what patterns match what in real time.

(如果可能的话,我很想使用regexr之类的东西来实时查看哪些模式与之匹配。)

Can anyone help me either find a pattern that works for my specifications, or to help me understand the pattern matching system?

(谁能帮助我找到适合我的规格的模式,或者帮助我了解模式匹配系统?)

I am using Oh My Zsh, but I don't think that affects this issue, as I have a file that modifies zstyle in the ~/.oh-my-zsh/custom directory, and the output of zstyle has rules I specified for matcher-list.

(我正在使用Oh My Zsh,但我认为这不会影响此问题,因为我在~/.oh-my-zsh/custom .oh ~/.oh-my-zsh/custom目录中有一个修改zstyle的文件,并且zstyle的输出具有我指定的规则匹配列表。)

  ask by beninato translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...