Isso é novo, mas em Bash 4.4 você pode defina a variável EXECIGNORE
:
aa. New variable: EXECIGNORE; a colon-separate list of patterns that will cause matching filenames to be ignored when searching for commands.
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.
Por exemplo:
$ EXECIGNORE=$(which pytest)
Ou usando o Correspondência de padrões :
$ EXECIGNORE=*/pytest