In bash, suppose I have this commands:

$ pyt[TAB][TAB]

99% of the time, I'd go for python. It's so annoying that pytest pop up and prevent me from typing only pyt[TAB][RETURN] to invoke python. Can I hide pytest from bash completion?

My limitations:

  1. I know that I can remove pytest binary at /usr/bin/pytest to prevent suggestion within bash. But what if I have no root access? What if pytest is an importance script that must exists in order to let other script work properly?

  2. Even though I can remove pytest binary (and I've done it before), some time when I upgrade my software, this script comes back again.

  3. I know that I can use alias to save keystrokes for my favorite application (maybe just p for python). But I don't like these non-standard abbreviation. Its kind of make me confuse when remote to other machines.

So, anyway to hide some commands from bash completion? Answer in other shell (zsh, fish, etc) is welcome since bash doesn't speed up my workflow lately.


This is rather new, but in Bash 4.4 you can set the EXECIGNORE variable:

aa. New variable: EXECIGNORE; a colon-separate list of patterns that will cause matching filenames to be ignored when searching for commands.

From the official documentation:


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.

For Example:

$ EXECIGNORE=$(which pytest)

Or using Pattern Matching:

$ EXECIGNORE=*/pytest
  • Work like a charm! – neizod Oct 6 '16 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.