Ubuntu – Make annoying executable invisible to bash tab completion (cd-it8 etc)

18.04auto-completionbashcommand line

When using the command line, cd is one of the most frequently used shell commands. I've gotten used to the ability to type cd, pressing tab, and then pressing tab again to see what directories there are to cd into. Ubuntu has recently started including the colord package and its tools start with cd. Now if I press cd and tab, I get this:

$ cd
cd                 cd-fix-profile     cd-it8             
cd-create-profile  cd-iccdump         

How can I make sure all those cd-* executables don't show up when I'm using the command line? I assume they are necessary for the OS, so I can't just move them out or rename them; however, I don't want them to be completed or even visible when I'm in bash.

Note that this is under bash 4.4.20(1) which is what comes with Ubuntu 18.04.

As an aside: are those executables still included in Ubuntu 20.04?

Best Answer

  • From Bash Variables,

    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.

    So add this to ~/.bashrc:


    I do not have those cd-* commands, but here is another example:

    $ ex<TAB>
    ex                          exit                        exo-open                    expiry
    exec                        exo-csource                 exo-preferred-applications  export
    exifautotran                exo-desktop-item-edit       expand                      expr
    $ xfc<TAB>
    xfce4-terminal          xfce4-terminal.wrapper  xfconf-query
    $ EXECIGNORE="*/ex?*:*/xfconf-query:"
    $ ex<TAB>
    ex      exec    exit    export
    $ xfc<TAB>
    $ xfce4-terminal

    It illustrates an important point: Shell builtins are not excluded (exec, exit and export are still suggested in the completion), since they are not searched using PATH.