gpt4 book ai didi

bash - bash补全的黑名单程序

转载 作者:行者123 更新时间:2023-11-29 09:00:58 24 4
gpt4 key购买 nike

Fedora 带有“gstack”和一堆“gst-”程序,当我试图快速输入我的 git 别名时,它们不断出现在我的 bash 补全中。它们当然与一千个其他程序一起安装在/usr/bin 下,所以我不能只是从我的 PATH 中删除它们的目录。在 Linux 中有什么方法可以将这些特定程序列入黑名单以防止出现完成?

我试过 FIGNORE 和 GLOBIGNORE 环境变量,但它们不起作用,看起来它们仅用于在您输入命令后完成文件。

最佳答案

2016 年,Bash 为此引入了一个选项。我正在复制 this newer answer 中的文本通过 zuazo :


这是相当新的,但在 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 Pattern Matching) 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

关于bash - bash补全的黑名单程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28243760/

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