我在一个目录中有许多名称相同但文件类型不同的文件:foo.aux foo.bbl foo.blg foo.log foo.out foo.pdf foo.tex
我希望能够输入 foo[Tab]
并让 zsh 始终自动完成到 .tex,然后是 .pdf,然后是 zsh 喜欢的任何顺序。有没有设置这种自动完成首选项?
如果相关,我正在使用 oh-my-zsh。
谢谢你的尽心帮助!
最佳答案
您可以使用 file-patterns
设置以您喜欢的任何方式对文件进行分类。对于您的情况,这应该有效:
# First, we define how to categorize the files.
zstyle ':completion:*' file-patterns '
*.tex(D-^/*):tex-files:"TEX file"
*.pdf(D-^/*):pdf-files:"PDF file"
*(D-*):executables:"executable file"
*(D-/):directories:"directory"
^*.(tex|pdf)(D-^/*):files:"other file"
'
# Then, we define in what order they should appear.
zstyle ':completion:*' group-order tex-files pdf-files executables directories files
# Finally, we need to enable group names, or the group order won't work.
zstyle ':completion:*' group-name ''
文档:(D-^/*)
) 关于zsh - 自动完成时如何让 zsh 更喜欢某些文件类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34898670/