Bash: Where to install completion?

From FVue
Jump to: navigation, search


I have written bash dots functions with autocompletion. What is the best place to install them?


Eh, multiple solutions? Maybe install function and completion separate, for all users at once. Drawback is that functions have to be exported to have them available in a non-login interactive shell?


Or creating a directory /etc/bash.bashrc.d which is executed from /etc/bash.bashrc. This has the benefit of easy upgrading individual scripts. And it's only sourced when necessary — within an interactive shell. And it's available for all users.

for s in /etc/bash.bashrc.d/*.sh ; do
    test -r $s && . $s
unset s

Or for a single user put files in a user directory ~/.bashrc.d invoked from ~/.bashrc, which makes it easy to upgrade individual scripts:

for s in ~/.bashrc.d/*.sh ; do
    test -r $s && . $s
unset s

See also

What happens when you invoke bash?


blog comments powered by Disqus