简体   繁体   English

在bash中指定两个文件扩展名完成

[英]Specifying two file extensions in bash complete

I am trying to modify bash complete properties. 我正在尝试修改bash完整属性。

I can exclude a file extension for a command thusly: 我可以这样排除命令的文件扩展名:

complete -f -X '*hi' vim

I want to specify two file names for exclusion. 我想指定两个文件名以进行排除。 How do I do this? 我该怎么做呢?

Note: the following command did not work. 注意:以下命令不起作用。

complete -f -X '(*hi|*o)' vim

One way to do this is to turn on Extended Globs . 一种方法是打开Extended Globs Run this at the command line, or add it to your .bashrc to make it permanent: 在命令行运行它,或将其添加到.bashrc以使其永久化:

shopt -s extglob

Now, your complete command can look like this: 现在,您的完整命令可能如下所示:

complete -f -X '*.@(hi|o)' vim

Quoting from Extended Globs in patterns : 扩展的Globs中引用模式

@(list): Matches one of the given patterns.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM