I'm having trouble trying to update automatically the bash completion in the current bash session when installing a package.

My package installs the completion file in /usr/share/bash-completion/completions/ but the completion does not work for the session that installs the package (with dpkg - i)

I tried running . /path/to/the/file and even . /etc/profile in the postinst script to no avail.

How could I do this?


Your package can’t do this on its own, because it doesn’t have access to the environment of the shell (if any) from which the installation was started. When you try to load the new completion in postinst, that only affects the shell instance which is running the postinst, and that’s not the same as the user’s shell instance.

Your completion will only be available in shells started after its installation, and there’s nothing you can (reasonably) do about that. End users who want the new completion immediately, without starting a new shell, will have to run

. /usr/share/bash-completion/bash_completion


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.