Fedora附带了“gstack”和一堆“gst-”程序,当我试图快速输入我的git别名时,这些程序一直出现在我的bash完成中.它们当然和/usr/bin一起安装在其他一千个程序中,所以我不能只从我的PATH中删除它们的目录.在
Linux中是否有任何方法可以将这些特定程序列入黑名单以便完成?
我已经尝试过FIGNORE和GLOBIGNORE环境变量,但它们不起作用,看起来它们只是在您输入命令后才能完成文件.
2016年,Bash为此推出了一个选项.我将在
zuazo年复制
this newer answer的文字:
这是相当新的,但在Bash 4.4中您可以设置EXECIGNORE变量:
aa. New variable: EXECIGNORE; a colon-separate list of patterns that
will cause matching filenames to be ignored when searching for commands.
从the official documentation开始:
EXECIGNORE
A colon-separated list of shell patterns (see 07004) defining the list of filenames to be ignored by command search using
PATH. Files whose full pathnames match one of these patterns are not
considered executable files for the purposes of completion and command
execution via PATH lookup. This does not affect the behavior of the [,
test,and [[ commands. Full pathnames in the command hash table are
not subject to EXECIGNORE. Use this variable to ignore shared library
files that have the executable bit set,but are not executable files.
The pattern matching honors the setting of the extglob shell option.
例如:
$EXECIGNORE=$(which pytest)
或者使用Pattern Matching:
$EXECIGNORE=*/pytest