gpt4 book ai didi

zsh - 自动完成时如何让 zsh 更喜欢某些文件类型

转载 作者:行者123 更新时间:2023-12-03 21:36:45 34 4
gpt4 key购买 nike

我在一个目录中有许多名称相同但文件类型不同的文件:
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 ''
文档:
  • Glob qualifiers ( (D-^/*) )
  • Completion system configuration
  • 关于zsh - 自动完成时如何让 zsh 更喜欢某些文件类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34898670/

    34 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com