I have a git repository where I keep some statically-linked binaries along with related man files and bash completion files, which are all 'installed' using GNU Stow to make the symlinks.

I have previously put the symlinks for the bash completion files in /etc/bash_completion.d with no issues, but recently I have started putting them in /usr/share/bash-completion/completions instead, as I thought it was a more correct location for them, seeing as the binaries were going in /usr/local/bin and the man files in /usr/local/share/man.

Everything works as before apart from four specific bash completion files, which are no longer working when placed in this new location. These are:

And these two for fzf:

I have 20 other bash completion files that work fine. What is it about these specific bash completion files that make them work while in /etc/bash_completion.d with no issues but not in /usr/share/bash-completion/completions?

EDIT: They also don't work in ~/.local/share/bash-completion/completions either.

Additional information:

The files are sourced by the standard Debian/Ubuntu .bashrc lines:

# Enable programmable completion features
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion

In both locations it is not the contents on directories are that being sourced, but these two files:



The second file simply points to the first file if NOT shopt -oq posix. On my setup:

$ if ! shopt -oq posix; then echo "not posix"; fi
not posix

I think the answer must be in /usr/share/bash-completion/bash_completion.


I tried replacing bash_completion with the latest version but that doesn't work either.



These files do not work when placed in ~/.local/share/bash-completion/completions either.

  • Are you sourcing them? Commented Sep 17, 2022 at 14:59
  • @ArkadiuszDrabczyk Yes, as I mentioned, 29 other completion files in the same location work fine. There is something about these four specific files that are causing them to not work when in the new location.
    – paradroid
    Commented Sep 17, 2022 at 22:49
  • What does type _git_identity say for example? Commented Sep 17, 2022 at 23:07
  • @ArkadiuszDrabczyk bash: type: _git_identity: not found
    – paradroid
    Commented Sep 17, 2022 at 23:29
  • What if you source git-identity.bash-completion manually? Commented Sep 17, 2022 at 23:33

1 Answer 1


Completion files in /etc/bash_completion.d are always sourced immediately by bash_completion for backwards compatibility. The completions directories, on the other hand, lazily source the scripts inside, that is, a particular completion file isn't sourced until completion is requested for that command. The file to source is determined by its name, thus it must have the same name as the command you're trying to get completions for. So, for example, tmux.completion.bash should be symlinked as completions/tmux and not completions/tmux.completion.bash.

Finally, as you're putting everything else under /usr/local, note that you can put the completion scripts there as well: /usr/local/share/bash-completion/completions.

  • 1
    Excellent, thanks. I should have noticed that these files are not named like all the others that do work. I'll add they also work with a .bash or .sh suffix. This presents a problem with the fzf files which don't work when concatenated to fzf.bash, but I can always specifically source those files in the same location from .bashrc.
    – paradroid
    Commented Sep 18, 2022 at 16:44
  • This makes sense, but it doesn't seem to be true for me. My system has /usr/share/bash-completion/completions/git, but I have no git completion (it just attempts to complete filenames in all scenarios). If I run source /usr/share/bash-completion/completions/git, I then have "smart" completion in that terminal. I'm fine with sourcing it in my .bashrc, but your answer suggests I shouldn't have to. Am I missing something?
    – cdgraham
    Commented May 21, 2023 at 2:41
  • Do completions work for other commmands? If not, make sure you're sourcing /usr/share/bash-completion/bash_completion. Other than that you can try starting bash with bash -x and completing as usual (type git followed by Tab), which should output a bunch of executed commands. When git completion is working properly you should see __load_completion git execute, which searches for the completions/git script and sources it. Commented May 22, 2023 at 22:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .